How to use the request-promise-native.post function in request-promise-native

To help you get started, we’ve selected a few request-promise-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github actionhero / actionhero / __tests__ / servers / web / routes / routes.ts View on Github external
test("regexp matches will provide proper variables", async () => {
      const body = await request.post(url + "/api/login/123").then(toJson);
      expect(body.requesterInformation.receivedParams.action).toEqual("login");
      expect(body.requesterInformation.receivedParams.userID).toEqual("123");

      const bodyAgain = await request
        .post(url + "/api/login/admin")
        .then(toJson);
      expect(bodyAgain.requesterInformation.receivedParams.action).toEqual(
        "login"
      );
      expect(bodyAgain.requesterInformation.receivedParams.userID).toEqual(
        "admin"
      );
    });
github leanix / leanix-reporting-cli / src / api-token-resolver.ts View on Github external
public static getAccessToken(host: string, apiToken: string) {
  const base64ApiToken = new Buffer('apitoken:' + apiToken).toString('base64');
  const options = {
    url: host + '/services/mtm/v1/oauth2/token',
    headers: { 'Authorization': 'Basic ' + base64ApiToken },
    form: { grant_type: 'client_credentials' }
  };

  return rp.post(options)
    .then(response => JSON.parse(response)['access_token']);
}
github looker / actions / src / actions / mparticle / mparticle_transaction.ts View on Github external
async sendChunk(rows: Hub.JsonDetail.Row[], mapping: any) {
    const chunk = rows.slice(0)
    const body: MparticleBulkEvent[] = []
    chunk.forEach((row: Hub.JsonDetail.Row) => {
      const eventEntry = this.createEvent(row, mapping)
      body.push(eventEntry)
    })
    const options = this.postOptions(body)
    await httpRequest.post(options).promise().catch((e: any) => {
      this.errors.push(`${e.statusCode} - ${mparticleErrorCodes[e.statusCode]}`)
    })
  }
github SpeedCurve-Metrics / speedcurve-cli / src / api.ts View on Github external
post(url: URL, data = {}) {
		log.http("POST", `${logFriendlyUrl(url)} ${truncate(JSON.stringify(data), 60)}`)

		return r
			.post({
				uri: url.href,
				json: true,
				form: data,
				headers: {
					"user-agent": `speedcurve-cli/${VERSION}`
				}
			})
			.catch(this.normaliseErrorResponse)
	}

request-promise-native

The simplified HTTP request client 'request' with Promise support. Powered by native ES6 promises.

ISC
Latest version published 4 years ago

Package Health Score

49 / 100
Full package analysis