I am able to change the globally declared searchText from an empty string to "cat" by writing in my input field, but for some reason that isn't updating the string interpolated value of ${searchText}.
-
1) add the relevant code as text, not an image. 2) interpolated strings don't "change" over time, they are what they are based on the substitutions at the time of evaluation.crashmstr– crashmstr2021-01-05 17:10:13 +00:00Commented Jan 5, 2021 at 17:10
-
Please edit your question to include the code as text, do not post a link to a painting of it!Bergi– Bergi2021-01-05 17:10:19 +00:00Commented Jan 5, 2021 at 17:10
Add a comment
|
1 Answer
In order to make that dynamic you should be doing something like this:
const apiUrl = () => `...${searchText}...`
You create a function to be executed and return the current value when you need it.
And then when you need to call it:
// just an example...
const url = apiUrl()
fetch(url)...