當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。