I use node.js as a client that makes some http requests. I want to use http in syncronous manner. I know node.js has synchronous versions of file system apis. Is there something for http also?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There isn’t a synchronous function for doing http requests in Node.js. There are only a few synchronous function in Node, mostly which are related to file operations.
You can use promises however to achieve this, but looks to me more complicated that actually writing a few lines of asynchronous code. ( example of promises libraries: https://github.com/medikoo/deferred or https://github.com/megakorre/promise ).
You should really try to write asynchronous code in Node, since Node is all about that (async).