Install and use SuperAgent
masterSuperAgent is a lightweight Ajax API designed for flexibility, readability, and low learning curve. It works in both the browser and Node.js environments. You can initiate a request by calling methods on the request object and then sending it using .then(), .end(), or await.
request
.post('/api/pet')
.send({ name: 'Manny', species: 'cat' })
.set('X-API-Key', 'foobar')
.set('Accept', 'application/json')
.then((res) => {
alert('yay got ' + JSON.stringify(res.body));
});