Pass parameters to GET request in fetch API
does anyone know how to pass parameters in a GET request using fetch()?
p.s. I can't use Axios inside the web worker.
Use a query string
If you like the idea of a params object, then you can construct the URL using a URLSearchParams
object:
let url = new URL('https://sl.se')
url.search = new URLSearchParams({
lat:35.696233,
long:139.570431
})
fetch(url)
I was actually looking for a way to convert Object to query string parameters.
looks like it works properly.
Please or to participate in this conversation.