To make synchronous requests in Node.js, we use the sync-request
module.
For instance, we write
const request = require("sync-request");
//...
try {
const res = request("GET", url);
} catch (e) {
console.log(e);
}
to call request
to make a get request to url
.
We use the catch block to catch any request errors.