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

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

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

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



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

示例1: queryTradeInfo

 /**
  * 提供會員系統查詢 O'Pay 訂單資訊,可透過此 API 來過濾是否為有效訂單,更多應用請參考 [FAQ](https://forum.allpay.com.tw/forum.php?mod=viewthread&tid=95&extra=page%3D1)
  */
 public async queryTradeInfo(info: ITradeInfo) {
   let body = extend<ITradeInfo>(
     {
       TimeStamp: Math.floor(Date.now() / 1000),
       MerchantID: this.config.MerchantID,
       PlatformID: ""
     },
     info
   );
   let check = new V();
   check.verify(body, {
     TimeStamp: [V.isNumber],
     MerchantID: [V.isString, V.limitLength(1, 10)],
     MerchantTradeNo: [
       V.isString,
       V.limitLength(1, 20),
       V.isNumberOrEnglishLetter
     ]
   });
   if (check.invalid) throw check.errorMessage;
   body.CheckMacValue = getMacValue(body, this.config);
   let data = qs.stringify(body);
   return request
     .post(this.config.QueryTradeInfoUrl, {
       form: body,
       headers: {
         "Content-Type": "application/x-www-form-urlencoded",
         "Content-Length": Buffer.byteLength(data)
       },
       json: false
     })
     .then(qs.parse);
 }
开发者ID:EJayCheng,项目名称:oPay-ts,代码行数:36,代码来源:oPay.ts


示例2: post

 private async post(url:string, dtoContract:any, data:any) {
   try {
     const json = await rp.post({
       url: Contacter.protocol(this.port) + this.fullyQualifiedHost + url,
       body: data,
       json: true,
       timeout: this.options.timeout
     });
     // Prevent JSON injection
     return sanitize(json, dtoContract);
   } catch (e) {
     throw e.error;
   }
 }
开发者ID:duniter,项目名称:duniter,代码行数:14,代码来源:contacter.ts


示例3: getAccessTokenAsync

    // Redeem the authorization code for an access token
    public async getAccessTokenAsync(code: string): Promise<UserToken> {
        let params = {
            grant_type: "authorization_code",
            code: code,
            client_id: this.clientId,
            client_secret: this.clientSecret,
            redirect_uri: config.get("app.baseUri") + callbackPath,
        } as any;

        let responseBody = await request.post({ url: accessTokenUrl, form: params, json: true });
        return {
            accessToken: responseBody.access_token,
            expirationTime: Date.now() + (responseBody.expires_in * 1000),
        };
    }
开发者ID:billbliss,项目名称:microsoft-teams-sample-auth-node,代码行数:16,代码来源:LinkedInProvider.ts


示例4: e2e

async function e2e(filePath: string): Promise<void> {
    console.log(`Running e2e for: ${filePath}`);

    if (!fs.existsSync(filePath)) {
        console.error("File not found");
        throw Error("File not found");
    }

    const result = await request.post({
        url: "https://wt-9017166451e5dc00461b648d19f5e8da-0.sandbox.auth0-extend.com/docx-validator",
        formData: {
            document: fs.createReadStream(filePath),
        },
    });

    return result;
}
开发者ID:dolanmiu,项目名称:docx,代码行数:17,代码来源:e2e.ts


示例5: async

        return async (req: express.Request, res: express.Response) => {
            let encodedToken = res.locals.encodedToken;
            let token = res.locals.token;
            let tenantId = token["tid"];
            let graphAccessToken: string;

            // The version of the endpoint to use for OBO flow must match the one used to get the initial token
            switch (token.ver) {
                case "1.0":
                {
                    // AAD v1 endpoint token
                    let tokenEndpoint = `https://login.microsoftonline.com/${tenantId}/oauth2/token`;
                    let params = {
                        grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
                        assertion: encodedToken,
                        client_id: this.clientId,
                        client_secret: this.clientSecret,
                        resource: "https://graph.microsoft.com",
                        requested_token_use: "on_behalf_of",
                        scope: "openid",
                    } as any;
                    let tokenResponse = await request.post({ url: tokenEndpoint, form: params, json: true });
                    graphAccessToken = tokenResponse.access_token;
                    break;
                }

                case "2.0":
                {
                    // AAD v2 endpoint token
                    let tokenEndpoint = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`;
                    let params = {
                        grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
                        assertion: encodedToken,
                        client_id: this.clientId,
                        client_secret: this.clientSecret,
                        requested_token_use: "on_behalf_of",
                        scope: "https://graph.microsoft.com/User.Read",
                    } as any;
                    let tokenResponse = await request.post({ url: tokenEndpoint, form: params, json: true });
                    graphAccessToken = tokenResponse.access_token;
                    break;
                }

                default:
                    throw new Error(`Unsupported Azure AD endpoint version ${token.ver}`);
            }

            // The OBO grant flow can fail with error interaction_required if there are Conditional Access policies set.
            // This example does not handle that. See https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of#error-response-example

            // Get user profile from Graph
            let options = {
                url: "https://graph.microsoft.com/v1.0/me",
                json: true,
                headers: {
                    "Authorization": `Bearer ${graphAccessToken}`,
                },
            };
            let profile = await request.get(options);

            // Return profile as response
            res.status(200).send(profile);
        };
开发者ID:billbliss,项目名称:microsoft-teams-sample-auth-node,代码行数:63,代码来源:GetProfileFromGraph.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript request-promise-json.get函数代码示例发布时间:2022-05-25
下一篇:
TypeScript request-promise.get函数代码示例发布时间: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