Reputation: 965
I have an url like:
http://some-url:3978/api/stream
How Can I listen to it in node to see all incoming messages ?
Or the equivalent of
curl http://localhost:3978/api/stream
Upvotes: 0
Views: 302
Reputation: 11496
If you want your data on backend Use a package called as postman-request. simplest way to make HTTP calls (GET,POST), supports promise too, another alternative is to use axios which works in browser as well as with express too.
If you want this from client side, you can use browser based API like fetch,axios,xmlhttpprequests
npm i postman-request //for installation
//example
const request = require('postman-request');
request('http://www.google.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
Upvotes: 1