Rayes
Rayes

Reputation: 94

How to pass a variable in form action url?

I am trying to pass a changing variable in form action url but it is not reading it correctly.

<form action='/api/getRSS/${this.state.savedKey}' method="get">
<button type="submit" value="Submit">Submit</button>
</form>

The output is like this: http://localhost:3000/api/getRSS/$%7BsavedKey%7D?

It is not what I want as the key is for example -LGtVU0YN3RLACIDAFEQ. How is it possible for me to pass the right key? I tried to console this.state.savedKey and it was the correct key (logged it just before the form, and tried after as well, and it works fine).

Upvotes: 2

Views: 1018

Answers (1)

keul
keul

Reputation: 7819

Should be

<form action={`/api/getRSS/${this.state.savedKey}`} method="get">

Upvotes: 1

Related Questions