Tuesday 27 March 2018

Is there an easy way to store a JSON return into a variable and work with after that?

So, long of the short, I am trying to work with an npm that returns a JSON file with stock information. Here is a link to the NPM:LINK: https://ift.tt/2Gbd1F1, all I want to do is to pull say a daily quote for AAPL. Well, I can see I can do this from the API instructions:alpha.data.daily('AAPL', 'compact', 'json', 'daily').then(data =>{ console.log(data); }); Well, that works and brings back 100 different stock days of information about the stock.However, I want to try to make that useful. I am attempting to set that data that is consoled out to a variable. Then, I want to parse through the JSON and say get data from a specific day. Say, the opening for a specific date.I have tried several ways to do this, but can't seem to figure out how to do it. Attempts have brought "promise" to also bringing just empty variables.I am basically lost at this point and googling doesn't seem to be coming up with a good answer. Does anyone know a good way I could set an API call to a variable and then parse through the JSON once it is in that variable?Thanks for any help.

Submitted March 27, 2018 at 05:18AM by osualgorithmstuff

No comments:

Post a Comment