Home > database >  React - add variable in URL for fetch?
React - add variable in URL for fetch?

Time:07-06

I have a fetch:

fetch(`https://example/e1/e11/${variable1}?param=A1&include=metadata`, {
  "method": "GET"...

What is wrong to declarate the variable1 in this way? With this it works:

https://example/e1/e11/$apple?param=A1&include=metadata

CodePudding user response:

You need to do this:

fetch(`https://example/e1/e11/'   variable1   '?param=A1&include=metadata`, {

"method": "GET"...

  • Related