Every line of 'axios post request with body' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
24 function _axiosPost() { 25 var args = []; 26 for (var _i = 0; _i < arguments.length; _i++) { 27 args[_i] = arguments[_i]; 28 } 29 return new Promise(function (resolve, reject) { 30 jsHelper.apply(exports.axios.post, exports.axios, args) 31 .then(function (response) { 32 resolve(response); 33 }) 34 .catch(function (err) { 35 reject(err); 36 }); 37 }); 38 }
33 static async post(url, body) { 34 return new Promise(async (res, rej) => { 35 try { 36 const headers = Requests.makeHeaders(); 37 const json = await Requests.makeRequest(url, 'POST', headers, body); 38 res(json); 39 } catch (err) { 40 rej(err); 41 } 42 }); 43 }
58 export function post(requestUrl, config = {}) { 59 let postData = typeof config.body == 'string' 60 ? config.body 61 : JSON.stringify(config.body || {}) 62 let parsed = url.parse(requestUrl) 63 let options = { 64 hostname: parsed.hostname, 65 port: parsed.port, 66 path: parsed.path, 67 method: 'POST', 68 headers: Object.assign({ 69 'Content-Type': 'application/json', 70 'Content-Length': Buffer.byteLength(postData) 71 }, config.headers) 72 } 73 if (parsed.protocol == 'https:') { 74 return dispatchRequest(true, options, postData) 75 } else { 76 return dispatchRequest(false, options, postData) 77 } 78 }
104 post(requestUrl: string, fragmentName: string, data?: object, options?: request.CoreOptions): Promise<{ response: request.Response, data: any }> { 105 if (!HttpClient.httpClient && !HttpClient.httpsClient) this.init('PuzzleJs Default Client'); 106 107 const client = requestUrl.startsWith('https') ? HttpClient.httpsClient : HttpClient.httpClient; 108 109 return new Promise(function (resolve, reject) { 110 client 111 .post({ 112 url: requestUrl, 113 json: data, 114 ...options 115 }, (err, response, data) => { 116 if (err) reject(err); 117 118 resolve({ 119 response, 120 data 121 }); 122 }); 123 }); 124 }
38 static post>( 39 url: string, 40 // tslint:disable-next-line:no-any 41 data?: any, 42 config?: AxiosRequestConfig, 43 ): Promise { 44 return axios.post(url, data, config); 45 }
127 post(url: string, body: string, options?: RequestOptionsArgs): Observable { 128 return httpRequest( 129 this._backend, 130 new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})), 131 options, RequestMethod.Post, url))); 132 }
40 POST(data){ 41 return Http.method(this, 'POST', data); 42 }
160 async function post(url, endpoint, _body, options) { 161 function createBody(_body, options) { 162 // array 163 if (Array.isArray(_body)) return _body; 164 // object 165 const body = Object.assign({}, _body); 166 const configTxParams = options.config ? options.config.txParams : undefined; 167 // in order of priority: 1:body, 2:options, 3:config, 4:default 168 body.txParams = Object.assign( 169 { gasLimit: 32100000000, gasPrice: 1 }, 170 configTxParams, 171 options.txParams, 172 _body.txParams 173 ); 174 return body; 175 } 176 177 const body = createBody(_body, options); 178 return ax.post(url, endpoint, body, options); 179 }
101 post(config) { 102 config.method = 'post'; 103 config.data = HttpClient.mkFormR(config.data); 104 105 config.headers = Object.assign({ 106 'Content-Type': 'application/x-www-form-urlencoded', 107 'Content-Length': Buffer.byteLength(config.data) 108 }, this.clientHeaders, config.headers); 109 110 return new Promise((resolve, reject) => { 111 Axios(config).then(response => { 112 this.handleResponse(response); 113 resolve(response.data); 114 }).catch(error => { 115 logResponse(error.response); 116 reject(error); 117 }); 118 }); 119 }
15 post(url: string, body: any, options?: RequestOptions) { 16 let requestOptions = options || RequestHelper.generateHeaders({ "Content-Type": "application/json" }); 17 let xhr = Utilities.isNull(requestOptions) ? this._http.post(url, JSON.stringify(body)) : this._http.post(url, JSON.stringify(body), requestOptions); 18 return this._json(xhr); 19 }