Hello I have the following code
export default function getCharacters (){
return fetch(`http://gateway.marvel.com/v1/public/comics?ts=9&apikey=${PUBLIC_KEY}&hash=${HASH}`)
.then(response => response.json())
.then(json =>{
console.log(json)
})
}
Is there a way to put the public key and the hash in the fetch method, that is not inside the url as I have it in the code? In the style that you can put the method for example.
If what you mean is a parameter constructor, in order not to concatenate them directly in the URL, you can use the URLSearchParams class
In fact, it is the most recommended way, since that class is responsible for correctly encoding invalid characters for a URL.