How can i correctly past the JS Object to the function in the template string correctly

const payload = {
test1: 1,
test2: 2,
};

const links = `
<a onClick="Lock('/myurl', ${payload});">click me</a>
`;


const Lock = (url, payload) => console.log(payload)
const payload = {
test1: 1,
test2: 2,
};

const links = `
<a onClick="Lock('/myurl', ${payload});">click me</a>
`;


const Lock = (url, payload) => console.log(payload)
an exception is being thrown because "payload" is not arriving in the function correctly. I have also tried
JSON.Stringify(payload)
JSON.Stringify(payload)
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server