Answers for "js require fetch"

15

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
1

how to install node fetch

$ npm install node-fetch --save
Posted by: Guest on June-10-2020
0

what is fetch javascript

/*
The fetch() method in JavaScript is used to request
to the server and load the information in the webpages.
The request can be of any APIs that returns the data of the format JSON or XML.
This method returns a promise.
*/

//Syntax:
fetch( url, options )
/*
URL: It is the URL to which the request is to be made.
Options: It is an array of properties. It is an optional parameter.
*/
Posted by: Guest on September-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language