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.
習慣沉默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. . .