const fetch = require('node-fetch');
// Plain text or HTML
(async () => {
const response = await fetch('https://github.com/');
const body = await response.text();
console.log(body);
})();
// JSON
const json = await response.json();
console.log(json);
// Simple Post
const response = await fetch('https://httpbin.org/post', {method: 'POST', body: 'a=1'});
// Post with JSON
const body = {a: 1};
const response = await fetch('https://httpbin.org/post', {
method: 'post',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
});