I have piece of code to put image URL from server part into JSON payload. I’ll show you what it looks like in code and what output gives the browser:
const url = `${apiUrl}/api/image/${barcode}`;
console.log("variable url:", url);
setPhotoUrl(`${apiUrl}/api/image/${barcode}`);
console.log("photoUrl when i put full url string:", photoUrl);
setPhotoUrl(url);
console.log("photoUrl when i put url variable inside:", photoUrl);
Output from browser:
browser output
Why this url don’t want to set in photoUrl constant even if it’s working in url variable?