To test our API server, we would need to run the server itself and send HTTP requests to it. There are many ways to send requests in Node.js:
- Using the request method provided by Node's native http module.
- Using the new Fetch Web API syntax: fetch is an improvement on the traditional XMLHttpRequest used to make AJAX (Asynchronous JavaScript And XML) requests from the client. We can use polyfills, such as isomorphic-fetch (https://www.npmjs.com/package/isomorphic-fetch), which will allow us to use the same syntax on the server.
- Using a library, such as request (https://www.npmjs.com/package/request), superagent (npmjs.com/package/superagent), axios (npmjs.com/package/axios), and many more.
Using the native ...