Every line of 'axios post json' 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.
8 export default function postJSON (url, body) { 9 return window.fetch(url, { 10 method: 'POST', 11 headers: { 12 'Content-Type': 'application/json' 13 }, 14 mode: 'cors', 15 body: JSON.stringify(body) 16 }) 17 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
10 function postJSON(endpoint, payload, csrf) { 11 return fetch(endpoint, { 12 method: "POST", 13 credentials: "same-origin", 14 headers: { 15 "Content-type": "application/json", 16 [HEADER]: csrf, 17 }, 18 body: JSON.stringify(payload), 19 }).then(json); 20 }
84 function _post_json(url,data, success, fail ) { 85 console.log( "----_post--start-------" ); 86 wx.request( { 87 url: url, 88 // header: { 89 // 'content-type': 'application/json', 90 // }, 91 method:'POST', 92 data:data, 93 success: function( res ) { 94 success( res ); 95 }, 96 fail: function( res ) { 97 fail( res ); 98 } 99 }); 100 101 console.log( "----end----_post-----" ); 102 }
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 }
25 export function postJSON(url: string, data) { 26 return fetch(url, { 27 method: "post", 28 body: JSON.stringify(data), 29 headers: { 30 "Content-Type": "application/json; charset=utf-8" 31 } 32 }).then((res) => { 33 if (res.ok) { 34 return res.json(); 35 } 36 throw new Error(res.statusText); 37 }) 38 }
25 export function apiPostJson(url, body, options = {}) { 26 const csrfToken = options.csrfToken || readCsrfFromPage(); 27 return apiFetch(url, { 28 method: 'POST', 29 body: JSON.stringify(body), 30 headers: { 31 'Accept': 'application/json', 32 'Content-Type': 'application/json', 33 'X-CSRF-Token': csrfToken 34 }, 35 ...(options.fetchOptions || {}) 36 }).then(response => response.json()); 37 }
334 function postJson(url, data, options) { 335 return json(url, data, options, 'POST'); 336 }
35 post(requestUrl, payload = {}) { 36 console.log('post', payload); 37 return this.request({ 38 url: requestUrl, 39 method: 'post', 40 body: payload 41 }); 42 }
97 static postJson(url, data, callback) { 98 var fetchOptions = { 99 method: 'POST', 100 headers: { 101 'Accept': 'application/json', 102 'Content-Type': 'application/json' 103 }, 104 body: JSON.stringify(data) 105 }; 106 107 if(networkIsOk()) 108 { 109 fetch(url, fetchOptions) 110 .then(res => res.text()) 111 .then(res => { 112 callback(res); 113 }) 114 .catch((err)=>{ 115 dataException(err); 116 }) 117 .done(); 118 } 119 }
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 }