Bg1987
Bg1987

Reputation: 1159

node.js Synchronous version of http.get

I want to write a tester that will test a http server I wrote for class. and I need a synchronous version of http.get/http.post

I wanted to make an object with a "test" method that will return true or false if the test passed but found no way to get the code to wait until the server responds to the get request.

Any suggestions on how this can be done?

Upvotes: 5

Views: 603

Answers (1)

JohnnyHK
JohnnyHK

Reputation: 311855

You can't do this with Node.js without horrible, busy-waiting hacks. Make your test method asynchronous as well, calling a callback parameter to deliver the results of the test back to the caller. Or use a different language for your unit testing.

Upvotes: 2

Related Questions