简体   繁体   中英

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);
});

You can use a framework like express.

Add a route to handle your client request.

Then build a response using your API response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM