async manifestJSON() { const response = await fetch( `https://api.github.com/repos/${this.repo.owner}/${this.repo.name}/contents/manifest.json` ); return JSON.parse(Buffer.from((await response.json()).content, 'base64').toString()); }
const processJob = async () => { debug('pinging compose to start on-demand db backup'); const result = await compose( `2016-07/deployments/${COMPOSE_DEPLOYMENT_ID}/backups`, { method: 'POST', } ); const json = await result.json(); debug(json); return; }
export default async function fetch() { const res = await this.page.evaluate((...args) => { // This is run within the browser's context meaning it's using the // browser's native window.fetch method. return fetch(...args).then(res => { const { url, status, headers } = res; return res.text().then(body => { return { url, status, body, headers }; }); }); }, ...arguments); return new Response(res.body, res); }
if (error === undefined || error.code === rateLimitErrorCode.toString()) { let response = await fetch(url, {method: 'POST', headers, body: JSON.stringify(app)}) messageData = await response.json()
try { const response = await fetch(url, {method: 'GET', headers}) messageData = await response.json() break } catch (e) {
if (error === undefined || error.code === rateLimitErrorCode.toString()) { let response = await fetch(url, {method: 'POST', headers, body: JSON.stringify(currentApp)}) messageData = await response.json()
function extractLinks (response: Response): { [name: string]: string } { try { return response.headers.get('Link').split(',').reduce((links, part) => { const match = part.match(parseRegexp) if (match) { links[match[2]] = match[1] } return links }, {} as { [name: string]: string }) } catch (e) { return {} } }
async function getGithubId (accessToken) { const response = await fetch('https://api.github.com/user', { headers: { Authorization: `token ${accessToken}`, Accept: 'application/json' } }) if (response.status !== 200) { throw Error(`getGithubId ${response.status} ${accessToken}`) } const { id: githubId } = await response.json() return githubId }
app.use('/json', (req, res) => { fetch('https://medium.com/@<account>/latest?format=json') .then((response) => { console.log("Data recieved!"); res.status(200); res.contentType('application/json'); response.text().then(json => res.send(new MParse().getArticles(json))); }) .catch((err) => { console.log("Failed to get data."); }); });
export function getRecipes (data) { return dispatch => { RecipeModel.getRecipes(data) .then(res => res.json()) .then(json => { dispatch({ type: ApiConstants.GET_RECIPES_SUCCESS, data: json }); }) .catch(err => { dispatch({ type: ApiConstants.GET_RECIPES_ERROR, data: err }) }) } }
const fetchResource = async (url) => { const response = await fetch(url) const html = await response.text() const resource = await metascraper({ html, url }) return { sources: ['resource'], ...resource, } }
app.get('/api/nonsecure/newsfeed', (req, res) => { fetch(`http://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=`+apiKey) .then(res => res.json()) .then(json => { // console.log(json) // res.send(json) res.json(json) }) .catch(err => res.send(err)) })