本文整理匯總了TypeScript中node-fetch.Headers類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Headers類的具體用法?TypeScript Headers怎麽用?TypeScript Headers使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Headers類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: buildDefaultHeaders
private buildDefaultHeaders()
{
const headers = new fetch.Headers();
headers.append("Accept", "application/json");
headers.append("Authorization", this.accessToken);
headers.append("User-Agent", `SWU-Logs (https://github.com/nozzlegear/swu-logs)`);
return headers;
}
示例2: test_fetchUrlWithOptions
function test_fetchUrlWithOptions() {
var headers = new Headers();
headers.append("Content-Type", "application/json");
var requestOptions: RequestInit = {
method: "POST",
headers: headers,
mode: 'same-origin',
credentials: 'omit',
cache: 'default',
redirect: 'manual'
};
handlePromise(fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions));
}
示例3: test_fetchUrlWithOptions
function test_fetchUrlWithOptions() {
var headers = new Headers();
headers.append("Content-Type", "application/json");
var requestOptions: RequestInit = {
method: "POST",
headers: headers,
compress: true,
follow: 10,
redirect: 'manual',
size: 100,
timeout: 5000
};
handlePromise(fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions));
}
示例4: test_headersRaw
function test_headersRaw() {
const headers = new Headers();
const myHeader = "foo";
headers.raw()[myHeader]; // $ExpectType string[]
}
示例5: require
import {get} from 'config';
import {spawn} from 'child_process';
const fetch = require('node-fetch');
const adminToken = get<string>('admin_token');
const organization = get<string>('organization');
const api = `https://api.github.com/orgs/${organization}/members`;
const headers = new fetch.Headers();
headers.set('Accept', 'application/json');
headers.set('Authorization', `Token ${adminToken}`);
function createUser(username: string): Promise<string> {
return new Promise((sucess, failure) => {
let p = spawn('sh', ['src/adduser.sh', username]);
p.stdout.on('exit', (code) => {
if (code) {
failure(`${username} could not be created`);
}
else {
sucess(username);
}
});
});
}