1const fetch = require('node-fetch'); //npm install node-fetch
2
3fetch('https://httpbin.org/post', {
4 method: 'POST',
5 body: 'a=1'
6})
7 .then(res => res.json())
8 .then(json => {
9 // Do something...
10 })
11 .catch(err => console.log(err));
1 fetch('https://api.github.com/users/github')
2 .then(res => res.json())
3 .then(json => console.log(json));