Answers for "fetch em node"

29

node js fetch

const fetch = require('node-fetch');	//npm install node-fetch

fetch('https://httpbin.org/post', {
  method: 'POST',
  body: 'a=1'
})
  .then(res => res.json())
  .then(json => {
	// Do something...
  })
  .catch(err => console.log(err));
Posted by: Guest on June-02-2020
0

node-fetch

// mod.cjs
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
Posted by: Guest on September-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language