I am creating api in NodeJS in api response I am getting /
this characters
Below is my api response:
static async getAdminOrders(logId, callback) {
logger(logId, `Getting all orders of the stylist ${logId}`);
const queryStr = 'SELECT order_details FROM stylist_order';
Util.executeQuery(queryStr,logId).then((result) => {
callback(false, result || [], Util.statusCodes.SUCCESS);
var str = JSON.stringify(result);
// Remove \ from the string
var str1 = str.replace(/\\/g,'');
// Convert updated string back to object
var newObj = JSON.parse(str1);
console.log(newObj);
}).catch((error) => {
logger(logId, error);
callback(true, { message: 'Failed to fetch order detials' }, Util.statusCodes.INTERNAL_SERVER_ERROR);
});
}
It is not returning object back after removing unwanted characters in console but when I am doing console.log(str1)
its returning string without /
. Issue is newObj
is not showing.
Someone let me know what I am doing wrong.