Ad

Client-side Js To Fetch Node.js API Calls

I am pretty new to node.js but I am using it to fetch data from an API. I want to return the response data to my client side js to be manipulated and injected into an html page. Pretty basic idea there, now do I make an HTTP request from the client side to my node.js to retrieve the JSON response text? How exactly do the client and server side communicate with eachother in this case?

factual.get(/t/places-us, {filters:{"locality":"seattle"}, {category_ids:{"$includes_any":[48, 50, 52]}}}, function (error, res) {
     console.log(res.data);
});
Ad

Answer

You can use a framework like express.

Add a route to handle your client request.

Then build a response using your API response.

Ad
source: stackoverflow.com
Ad