I'm JS novice,
My problem is that I have a var resortuid its value is from PHP (it's working). I need to open a json file with resortuid in link. In other words I need to replace XXXX in url with resortuid var. I'm sure that it is a banal question, but not for me.
EDIT: codefrom first response is working on SO, but not in TYPO3 fluid template, my new question is how to pass it to fluid template?
var resortuid = '1125';
var settings = {
"url": "https://aaa.aa/XXXX_simple.json",
"method": "GET",
"timeout": 0,
};
You can use JavaScript Template literals:
const resortuid = '1125';
const settings = {
"url": `https://aaa.aa/${resortuid}_simple.json`,
"method": "GET",
"timeout": 0,
};
console.log(settings.url)
By the way, Var, Let, and Const – What's the Difference? might be worth reading.