Home  >  Q&A  >  body text

javascript - nodejs cannot get the result returned after sending a request using request-promise.

The background uses request-promise to send network requests, requests a third-party interface, and returns a json data. I manually define the json key, but the output value corresponding to this key shows undefined.

Code block:

The browser returns the result:

The background display result is:

Why is it undefined? ? ?
The returned value is json. I used the variable inside [], and the local browser test has no problem.

typechotypecho2697 days ago918

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-06-21 10:14:07

    Can you consider that the return form of {"20170620":"0","20170621":"0"} is not an object? typeof? Or use for in to traverse it to see if it is an encapsulated object. Maybe the result output by console.log is just an illusion. The encapsulated object just changes toString or valueOf. . .

    reply
    0
  • Cancelreply