Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await/async or .then options #137

Open
t5unamie opened this issue Dec 16, 2020 · 0 comments
Open

await/async or .then options #137

t5unamie opened this issue Dec 16, 2020 · 0 comments

Comments

@t5unamie
Copy link

I am trying to chain many unirest calls one after another where by I make decisions based on the previous rest call.

The problem is normal patterns I normally use don't work with unirest and I am trying to work out why.

what seems to happen is the .then is not respected

await unirest.get("https://apidojo-yahoo-finance-v1.p.rapidapi.com/stock/v2/get-financials").headers({ "x-rapidapi-key": process.env.RAPITOKEN, "x-rapidapi-host": "apidojo-yahoo-finance-v1.p.rapidapi.com", "useQueryString": true }).query({ "symbol": TICKER, "region": "US" }).then( async (resFIN) => { <nest unirest request here> }

another pattern I tried is
var something = await unirest.get("https://apidojo-yahoo-finance-v1.p.rapidapi.com/stock/v2/get-financials").headers({ "x-rapidapi-key": process.env.RAPITOKEN, "x-rapidapi-host": "apidojo-yahoo-finance-v1.p.rapidapi.com", "useQueryString": true }).query({ "symbol": TICKER, "region": "US" }).then( async (resFIN) => { <nest unirest request here> }

What I get back in this situation is defined.

when I try https://stackoverflow.com/questions/39604262/returning-a-promise-from-the-unirest-client

I don't get the body back. I only get the request details made.

Is there something I am missing about unirest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant