How to use the request-promise-native.get 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__ / integration / sendBuffer.ts View on Github external
test("Server should sendBuffer", async () => {
    const body = await request.get(url + "/api/sendBufferTest");
    expect(body).toEqual("Example of data buffer");
  });
github actionhero / actionhero / __tests__ / servers / web / routes / routes.ts View on Github external
test("returns application/json when the mime type cannot be determined for an action", async () => {
      const response = await request.get(
        url + "/api/mimeTestAction/thing.bogus",
        { resolveWithFullResponse: true }
      );
      expect(response.headers["content-type"]).toMatch(/json/);
      const body = JSON.parse(response.body);
      expect(body.matchedRoute.path).toEqual("/mimeTestAction/:key");
      expect(body.matchedRoute.action).toEqual("mimeTestAction");
    });
github actionhero / actionhero / __tests__ / core / staticFile / staticFile.ts View on Github external
test("should send back the cache-control header", async () => {
      const response = await request.get(url + "/simple.html", {
        resolveWithFullResponse: true
      });
      expect(response.statusCode).toEqual(200);
      expect(response.headers["cache-control"]).toBeTruthy();
    });
github actionhero / actionhero / __tests__ / integration / sendBuffer.js View on Github external
test('Server should sendBuffer', async () => {
    const body = await request.get(url + '/api/sendBufferTest')
    expect(body).toEqual('Example of data buffer')
  })
github spring-cloud / spring-cloud-dataflow-ui / ui / protractor-docker-plugin / index.js View on Github external
downloadFile(url, destinationFilePath) {
        console.log('Start downloading file from ' + url);
        const requestPromiseCall = requestPromise.get(url, { json: false }, (error, response, body) => {
            console.log('content-type:', response.headers['content-type']);
            console.log('content-length:', response.headers['content-length']);
            if (response.statusCode < 200 || response.statusCode > 299) {
                throw new Error('Failed to load page, status code: ' + response.statusCode);
            }
            return body;
        }).then(body => {
            const buffer = Buffer.from(body, 'utf8');
            fs.writeFileSync(destinationFilePath, buffer);
            console.log('File downloaded!');
        });
        return requestPromiseCall;
    }
    sleep(ms) {
github tabeyti / jenkins-jack / src / jenkinsService.ts View on Github external
public async get(endpoint: string) {
        let url = `${this._jenkinsUri}/${endpoint}`;
        return request.get(url).catch(err => {
            console.log(err);
            vscode.window.showWarningMessage(this._cantConnectMessage);
            return undefined;
        });
    }
github SpeedCurve-Metrics / speedcurve-cli / src / api.ts View on Github external
get(url: URL) {
		log.http("GET", logFriendlyUrl(url))

		return r
			.get({
				uri: url.href,
				json: true,
				headers: {
					"user-agent": `speedcurve-cli/${VERSION}`
				}
			})
			.catch(this.normaliseErrorResponse)
	}
github looker / actions / src / actions / datarobot / datarobot.ts View on Github external
async form(request: Hub.ActionRequest) {
    const form = new Hub.ActionForm()

    if (!request.params.datarobot_api_token) {
      form.error = "No DataRobot API Token configured; consult your Looker admin."
      return form
    }

    if (request.params.datarobot_url) {
      try {
        const normalizedDataRobotUrl = normalizeUrl(request.params.datarobot_url)
        await httpRequest.get(normalizedDataRobotUrl).promise()
        this.dataRobotUrl = normalizedDataRobotUrl
      } catch {
        form.error = "URL for on-premise instance is not valid."
        return form
      }
    }

    try {
      await this.validateDataRobotToken(request.params.datarobot_api_token)

      form.fields = [
        {
          label: "The name of the project to be created",
          name: "projectName",
          required: false,
          type: "string",
github looker / actions / src / actions / jira / jira_client.ts View on Github external
async getProjects() {
    if (!this.tokens) {
      throw "unauthenticated"
    }
    const baseUrl = await this.baseUrl()
    return https.get({
      url: `${baseUrl}/project`,
      headers: {
        Authorization: `Bearer ${this.tokens.access_token}`,
      },
      json: true,
    })
  }
github kjayasa / swagger-ts-client / src / lib / swaggerProvider / httpSwaggerProvider.ts View on Github external
public async provide(settings: ISettings, logger: ILogger): Promise{
        let response = null;
        if (this.userName && this.password){
            logger.info(`Requesting swagger definitions from ${this.url} ...`);
            response = await request.get(this.url).auth(this.userName, this.password, false);
            logger.info(`Received swagger definitions from ${this.url} ...`);
            return JSON.parse(response) as Swagger.Spec;
        }
        else{
            logger.info(`Requesting swagger definitions from ${this.url} ...`);
            response = await request.get(this.url);
            logger.info(`Received swagger definitions from ${this.url} ...`);
            return JSON.parse(response) as Swagger.Spec;
        }
    }
}

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