import * as AWS from 'aws-sdk'; import {IResponse, response} from './tools'; AWS.config.update({region: 'us-east-1'}); // Virginia export class Http { private request:any; constructor() { this.request = require("request"); } /** * Make http request. * * @param params * @param api */ public async post(body: {postData: any}, params: { url: string, headers: any }): Promise { try { // Build the post string from an object let post_data = body.postData; let tsevoresponse = ''; const respRequestHTTP = await new Promise((res, rej) => { this.request.post({ "headers": params.headers, "url": params.url, "body": JSON.stringify(post_data) }, async (error, resp, pres) => { if (error) { console.log(900, error); rej(response(false, error)); } tsevoresponse = await JSON.parse(pres); res(response(true, null, tsevoresponse)); }) }); return respRequestHTTP; } catch (error) { return response(false, error); } } }