当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript node-fetch.Headers类代码示例

本文整理汇总了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;
 }
开发者ID:nozzlegear,项目名称:swu-logs,代码行数:10,代码来源:client.ts

示例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));
}
开发者ID:KostyaTretyak,项目名称:DefinitelyTyped,代码行数:13,代码来源:node-fetch-tests.ts

示例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));
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:14,代码来源:node-fetch-tests.ts

示例4: test_headersRaw

function test_headersRaw() {
    const headers = new Headers();
    const myHeader = "foo";
    headers.raw()[myHeader]; // $ExpectType string[]
}
开发者ID:DanielRosenwasser,项目名称:DefinitelyTyped,代码行数:5,代码来源:node-fetch-tests.ts

示例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);
      }
    });

  });
}
开发者ID:Istar-Eldritch,项目名称:systemusers,代码行数:30,代码来源:index.ts


注:本文中的node-fetch.Headers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。