How to use the fetch function from cross-fetch
Find comprehensive JavaScript cross-fetch.fetch code examples handpicked from public code repositorys.
6 7 8 9 10 11 12 13 14 15
* @param {*} event - The Electron event object that triggered the submission of the mock request. * @param {*} postData - the JSON stringified object from the renderer that contains a "method", "endpoint" and "response" keys that will be used to create the mock endpoint. */ submitMockRequest: async (event, postData) => { try { const result = await fetch('http://localhost:9990/mock/', { method: 'POST', headers: { 'Content-Type': 'application/json', },
116
796
17
50 51 52 53 54 55 56 57 58 59 60
* @see {@link https://developer.mozilla.org/docs/Web/API/fetch} for more about the fetch API. * @returns {Promise<Response>} A promise for the response to the request. */ const scratchFetch = (resource, options) => { const augmentedOptions = applyMetadata(options); return fetch(resource, augmentedOptions); }; /** * Set the value of a named request metadata item.
115
55
35
+ 3 other calls in file
64 65 66 67 68 69 70 71 72 73 74
* @see {@link https://developer.mozilla.org/docs/Web/API/fetch} for more about the fetch API. * @returns {Promise<Response>} A promise for the response to the request. */ const scratchFetch = (resource, options) => { const augmentedOptions = applyMetadata(options); return crossFetch.fetch(resource, augmentedOptions); }; /** * Set the value of a named request metadata item.
115
55
35
+ 2 other calls in file
24 25 26 27 28 29 30 31 32 33
let statusCode = 200; let body; let response; try { response = await fetch(request); body = await response.json(); if (body.errors) statusCode = 400; } catch (error) { console.log(error)
1
3
6
+ 3 other calls in file
GitHub: EdwardSalter/SiteToRss
21 22 23 24 25 26 27 28 29 30 31 32
const origin = `${uri.protocol}//${uri.host}`; return new URL(url, origin).href; } async function getEntries() { const response = await fetch(SITE_URL); const page = await response.text(); const $ = load(page);
0
0
0
GitHub: EdwardSalter/SiteToRss
9 10 11 12 13 14 15 16 17 18 19 20
const PRODUCT_IMAGE_SELECTOR = "img"; const PRODUCT_LINK_SELECTOR = "a"; const PRODUCT_TIME_SELECTOR = ".lty-lottery-countdown-timer"; async function getProductInfo() { const response = await fetch(URL); const page = await response.text(); const $ = load(page);
0
0
0
cross-fetch.Headers is the most popular function in cross-fetch (24 examples)