Module not found: Error: Can't resolve 'encoding' in '/Users/jameshome/Documents/projects/brightworldappnativescript/node_modules/node-fetch/lib' code example
Example 1: 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));
Example 2: how to install node fetch
$ npm install node-fetch --save