How to use Douban's Open api? in nodejs

ask for advice: I used nodejs"s request module to get Douban open api to get a string of json data, and then I don"t know how to render the data to my ejs template. I don"t know if I cleared it, and if there is a boss to take a look at it for me.

Mar.16,2021

does anyone know the answer? Ask the boss for an answer.


Why don't you directly use Ajax to make a http request to Douban's api on your front end to get the data?


do not map the invitation code.

write your request in the last function of router.get in the middleware, and go out to the template in res.render after reaching the result. (you see, that's all I can say when you post it.)


the subject may not quite understand how Synchronize and asynchronous code are executed, and the request request interface is asynchronous. So there are two solutions:

  1. like the third respondent, put the req.render method in request , so that the result returned by Douban can be uploaded to your own page
  2. .
  3. use Promise or aynsc/await to turn asynchrony into Synchronize. Wait for the data from Douban to return before you render your template.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ad82-407d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ad82-407d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?