I am trying to remove the double quotes inside the string but was not able to do so.
var productName = "300" Table";
console.log(productName);
var newTemp = productName.replace('"', /'/g);
console.log(newTemp);
var requestData = JSON.stringify({
'product_name': productName,
'page_url': newTemp
});
var obj = JSON.parse(requestData);
console.log(obj);
It is throwing an error in the second line.
"after 300replaceone more time, a little more carefully. Read the documentation for string literals one more time, a little more carefully. Also, why are you stringifying the object, and then immediately parsing it again?var productName = "300" Table";is a syntax error. It makes it hard to help you when we don't know for sure what your actual starting point (the actual string) is.