Every line of 'fetch api post' 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.
110 public async fetchPost(requestURL: string, body: TBody, query?: string, requestOption?: RequestInit): Promise { 111 const finalRequestOption: RequestInit = Object.assign({ 112 method: 'POST', 113 headers: this.headers 114 }, { body }, requestOption); 115 const response: Response = await this.httpClient.fetch(this.getRequestURL(requestURL, query), finalRequestOption); 116 return response.json(); 117 }
61 static async post(url, data) { 62 return await Fetch.request( 63 url, 64 'POST', 65 data, 66 ); 67 }
14 post(url, data) { 15 return new Promise((resolve, reject) => { 16 fetch(url, { 17 method: 'POST', 18 headers: { 19 'Content-type': 'application/json' 20 }, 21 body: JSON.stringify(data) 22 }) 23 .then(res => res.json()) 24 .then(data => resolve(data)) 25 .catch(err => reject(err)); 26 }); 27 }
36 post(url, opts = {}) { 37 const defaults = { 38 method: 'POST', 39 headers: this._getHeaders() 40 }; 41 42 return fetch(URL.resolve(this.baseUrl, url), merge(defaults, opts)) 43 .then(this._handleResponse).catch(Fetch._handleError); 44 }
8 function fetchApi (endpoint, opts = {}) { 9 opts = assign({ 10 headers: { 11 'Content-Type': 'application/json' 12 } 13 }, base.opts, opts) 14 return fetch(`${base.url}/api/${endpoint}`, opts) 15 .then(response => { 16 if (response.status !== 200) { throw response } 17 switch (response.headers.get('Content-Type')) { 18 case 'application/json': return response.json() 19 default: return response.text() 20 } 21 }) 22 }
256 function directPost(url, params, headers = {}) { 257 return directRequest('POST', url, params, headers); 258 }
42 export function post(url, paramsObj) { 43 var result = fetch(url, { 44 method: 'POST', 45 credentials: 'include', 46 headers: { 47 'Accept': 'application/json, text/plain, */*', 48 'Content-Type': 'application/x-www-form-urlencoded'// 默认表单提交 49 }, 50 body: obj2params(paramsObj) 51 }); 52 53 return result; 54 }
34 post(endpoint: string, body: any, options?: RequestOptions) { 35 return this.http.post(this.url + '/' + endpoint, body, options); 36 }
51 createPost(data) { 52 const url = this._getFullUrl("/posts"); 53 const request = () => this.httpClient.post(url, {...data, is_published: true}); 54 return this._handleRequest(request); 55 }
17 static fetchAllPosts() { 18 return facade.get("/posts"); 19 }