本文整理汇总了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);
}
});
});
}