javascript - How to pass the value to the page after express calls the interface?
阿神
阿神 2017-05-31 10:36:51
0
5
773

As shown in the picture, I used http.get to request the interface and got the returned data. I now want to transfer the avatar to the index page, but after the http.get method is used, iconUrl is undefined. How can I transfer the data returned from the interface to the index page?

阿神
阿神

闭关修行中......

reply all(5)
曾经蜡笔没有小新

iconUrl must be undefined.
It’s a problem with the basic scope of js

左手右手慢动作

Put the sentence res.render into the req.on('end') callback

漂亮男人

Scope issue.
Because your variable iconUrl is declared in req.on, when res.render is called, the iconUrl variable in req.on cannot be found. Try putting the declaration of iconUrl in router.get.

phpcn_u1582

Change http.get to a synchronous method or use res.render in the callback. Be careful not to have the same parameter name, just change the alias.

阿神

Just write it in the end

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!