• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript request-promise-native.post函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中request-promise-native.post函数的典型用法代码示例。如果您正苦于以下问题:TypeScript post函数的具体用法?TypeScript post怎么用?TypeScript post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了post函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: createPipe

 public async createPipe(): Promise<any> {
     const options = {
         uri: "https://api.bespoken.link/pipe",
         headers: {
             "x-access-token": "4772616365-46696f72656c6c61",
         },
         body: {
             // The secret key for the Skill
             uuid: this._secretKey,
             diagnosticsKey: null,
             endPoint: {
                 // The unique name/ID for the skill
                 name: this._id,
             },
             http: {
                 url: "https://proxy.bespoken.tools",
             },
             path: "/",
             pipeType: "HTTP",
             proxy: true,
         },
         json: true, // Automatically parses the JSON string in the response
         timeout: 30000
     };
     const response = await post(options);
     // Spokes creates a endPointID but not return the endPoint name
     response.endPoint = {
         name: this._id,
     };
     return response;
 }
开发者ID:bespoken,项目名称:bst,代码行数:31,代码来源:spokes.ts


示例2: register

 async register(params) {
   const { payload } = params;
   // allow you to overload the client's baseUrl
   const { baseUrl = this.baseUrl } = payload;
   const url = `${baseUrl}/wallet`;
   const signature = this.sign({ method: 'POST', url, payload });
   return request.post(url, {
     headers: { 'x-signature': signature },
     body: payload,
     json: true
   });
 }
开发者ID:bitpay,项目名称:bitcore,代码行数:12,代码来源:client.ts


示例3: importAddresses

  async importAddresses(params) {
    const { payload, pubKey } = params;
    const url = `${this.baseUrl}/wallet/${pubKey}`;

    console.log('addAddresses:', url, payload); // TODO
    const signature = this.sign({ method: 'POST', url, payload });
    const h = { 'x-signature': signature };
    return request.post(url, {
      headers: h,
      body: payload,
      json: true
    });
  }
开发者ID:bitpay,项目名称:bitcore,代码行数:13,代码来源:client.ts


示例4: createDashboardSource

 public async createDashboardSource(id: string, secretKey: string) {
     const options = {
         uri: "https://source-api.bespoken.tools/v1/createSource",
         headers: {
         },
         body: {
             source: {
                 id,
                 secretKey,
                 name: id,
                 liveDebug: true,
             },
         },
         json: true,
         timeout: 30000
     };
     return post(options);
 }
开发者ID:bespoken,项目名称:bst,代码行数:18,代码来源:source-name-generator.ts


示例5:

rpn.post({ url, oauth }, (e, r, body) => {
  // Ideally, you would take the body in the response
  // and construct a URL that a user clicks on (like a sign in button).
  // The verifier is only available in the response after a user has
  // verified with twitter that they are authorizing your app.

  // step 2
  let req_data = qs.parse(body);
  let uri = 'https://api.twitter.com/oauth/authenticate'
    + '?' + qs.stringify({ oauth_token: req_data.oauth_token });
  // redirect the user to the authorize uri

  // step 3
  // after the user is redirected back to your server
  let auth_data: any = qs.parse(body);
  let oauth = {
    consumer_key: CONSUMER_KEY,
    consumer_secret: CONSUMER_SECRET,
    token: auth_data.oauth_token,
    token_secret: req_data.oauth_token_secret,
    verifier: auth_data.oauth_verifier,
  };
  url = 'https://api.twitter.com/oauth/access_token';

  rpn.post({ url, oauth }, (e, r, body) => {
    // ready to make signed requests on behalf of the user
    let perm_data: any = qs.parse(body);
    let oauth = {
      consumer_key: CONSUMER_KEY,
      consumer_secret: CONSUMER_SECRET,
      token: perm_data.oauth_token,
      token_secret: perm_data.oauth_token_secret,
    };

    url = 'https://api.twitter.com/1.1/users/show.json';
    let query = {
      screen_name: perm_data.screen_name,
      user_id: perm_data.user_id
    };
    rpn.get({ url, oauth, qs: query, json: true }, (e, r, user) => {
      console.log(user);
    });
  });
});
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:44,代码来源:request-promise-native-tests.ts


示例6: create

	async function create (folder: IAlbumFolder = null): Promise<IAlbumFile> {
		const albumFile = await AlbumFile.create({
			app: appId !== null ? appId : null,
			user: userId,
			folder: folder ? folder.id : null,
			dataSize: size,
			mimeType: mimetype,
			name: fileName,
			serverPath: null,
			hash: hash
		}) as IAlbumFile;
		try {
			const path = await request.post({
				url: `http://${config.fileServer.host}/register`,
				formData: {
					'file-id': albumFile.id,
					'passkey': config.fileServer.passkey,
					file: {
						value: file,
						options: {
							filename: fileName
						}
					}
				}
			});
			albumFile.serverPath = path;
			// 画像だった場合幅と高さを取得してプロパティに保存しておく
			if (/^image\/.*$/.test(mimetype)) {
				const properties = await getPictureProperty(file, fileName);
				if (properties) {
					albumFile.properties = properties;
				}
			}
			await albumFile.save();
			return albumFile;
		} catch (e) {
			// remove temporary document
			await albumFile.remove();
			if (e instanceof StatusCodeError) {
				throw e.message;
			}
			throw e;
		}
	}
开发者ID:Tosuke,项目名称:Misskey-API,代码行数:44,代码来源:add-file-to-album.ts


示例7: broadcast

 async broadcast(params) {
   const { payload } = params;
   const url = `${this.baseUrl}/tx/send`;
   console.log('[client.js.113:url:]', url); // TODO
   return request.post(url, { body: payload, json: true });
 }
开发者ID:bitpay,项目名称:bitcore,代码行数:6,代码来源:client.ts


示例8: Buffer

    x.pipe(resp);
  }
});

declare const resp: http.ServerResponse;
declare const req: rpn.RequestPromise;
req.pipe(rpn('http://mysite.com/doodle.png')).pipe(resp);

const r = rpn;
http.createServer((req, resp) => {
  if (req.url === '/doodle.png') {
    r.get('http://google.com/doodle.png').pipe(resp);
  }
});

rpn.post('http://service.com/upload', { form: { key: 'value' } });
// or
rpn.post('http://service.com/upload').form({ key: 'value' });
// or
rpn.post({ url: 'http://service.com/upload', form: { key: 'value' } }, (err, httpResponse, body) => { /* ... */ });

const data = {
  // Pass a simple key-value pair
  my_field: 'my_value',
  // Pass data via Buffers
  my_buffer: new Buffer([1, 2, 3]),
  // Pass data via Streams
  my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
  // Pass multiple values /w an Array
  attachments: [
    fs.createReadStream(__dirname + '/attachment1.jpg'),
开发者ID:enlight,项目名称:DefinitelyTyped,代码行数:31,代码来源:request-promise-native-tests.ts


示例9: main

async function main() {
    // Ensure that the database exists.

    let database = await initializeDatabase();

    // Retrieve the main page.

    console.log(`Retrieving page: ${DevelopmentApplicationsUrl}`);
    let body = await request({ url: DevelopmentApplicationsUrl });
    let $ = cheerio.load(body);

    // Examine the HTML to determine how many pages need to be retrieved.

    let pageCount = Math.max(1, $("tr.pagerRow td").length - 1);
    let eventValidation = $("input[name='__EVENTVALIDATION']").val();
    let viewState = $("input[name='__VIEWSTATE']").val();

    if (pageCount === 1)
        console.log(`There is ${pageCount} page to parse.`)
    else
        console.log(`There are at least ${pageCount} pages to parse.`)

    // Process the text from each page.

    for (let pageIndex = 1; pageIndex <= 50; pageIndex++) {  // as a safety precaution enforce a hard limit of 50 pages
        console.log(`Parsing page ${pageIndex}.`);

        // Retrieve a subsequent page.

        if (pageIndex >= 2) {
            try {
                let body = await request.post({
                    url: DevelopmentApplicationsUrl,
                    headers: { "Content-Type": "application/x-www-form-urlencoded" },
                    form: {
                        __EVENTARGUMENT: `Page$${pageIndex}`,
                        __EVENTTARGET: "ctl00$Content$cusResultsGrid$repWebGrid$ctl00$grdWebGridTabularView",
                        __EVENTVALIDATION: eventValidation,
                        __VIEWSTATE: viewState
                }});
                $ = cheerio.load(body);
                eventValidation = $("input[name='__EVENTVALIDATION']").val();
                viewState = $("input[name='__VIEWSTATE']").val();
            } catch (ex) {
                console.log(`Reached the last page: ${ex.message}`);
                break;
            }
        }

        // Use cheerio to find all development applications listed in the current page.

        for (let element of $("table.grid tr.normalRow, table.grid tr.alternateRow").get()) {
            let row = $(element).children("td").get().map(cell => $(cell).text().trim());
            if (row.length < 4)
                continue;

            let applicationNumber = row[0];
            let receivedDate = moment(row[1], "D/MM/YYYY", true);  // allows the leading zero of the day to be omitted
            let description = row[2];
            let address = row[3];

            // Check for a valid application number and a non-empty address.

            if (!/^[0-9]{3}\/[0-9]{1,5}\/[0-9]{2}$/.test(applicationNumber) || address === "")
                continue;
    
            await insertRow(database, {
                applicationNumber: applicationNumber,
                address: address,
                description: ((description === "") ? "No description provided" : description),
                informationUrl: DevelopmentApplicationUrl.replace(/\{0\}/g, applicationNumber),
                commentUrl: CommentUrl,
                scrapeDate: moment().format("YYYY-MM-DD"),
                receivedDate: receivedDate.isValid ? receivedDate.format("YYYY-MM-DD") : ""
            });
        }
    }
}
开发者ID:planningalerts-scrapers,项目名称:city_of_charles_sturt,代码行数:78,代码来源:scraper.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript request-promise-native.put函数代码示例发布时间:2022-05-25
下一篇:
TypeScript request-promise-native.jar函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap