0

I have written code to call an api, from this url -

https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=RO6QHBGM0A4VO7NT

And i want a user to enter a value in the site that the api takes in and concatenates to other values necessary to pull down the data.

The url as it is above, calls the api correctly, but when I try to replace the MSFT with actual user input the api call becomes invalid.

I have tried concatenating input with the url by replacing msft with let input = $('#stockInput').val() but to no avail.

The id of the element the user types in is stockInput.

3
  • How did you append it. Even give that entire line how you are replacing msft with $('#stockInput').val() Commented Mar 18, 2018 at 8:19
  • i saved it under a variable called input and then replaces msft with input Commented Mar 18, 2018 at 12:35
  • Post what you tried so that we can see whats wrong with it Commented Mar 18, 2018 at 14:18

1 Answer 1

1

If i'm right you want pass the input from the user as a query param to the api call.

let input = $('#stockInput').val();
let url = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol="+input+"&apikey=RO6QHBGM0A4VO7NT";
// make your API call with the url
Sign up to request clarification or add additional context in comments.

2 Comments

yea i tried this and it still gives me the same error.
Kindly post your code snippet, so we can see what's wrong

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.