Remove default single quote of string .Tried replace but not working

var data = {Shop : "Shopename", email : "email@gmail.com", name : "name"},{Shop : "Shopename2", email : "email2@gmail.com", name : "name2"};

var data2exportforexcel =[data];
//wanted data
  [{Shop : "Shopename", email : "email@gmail.com", name : "name"},{Shop : "Shopename2", email : "email2@gmail.com", name : "name2"}];

//data i get

[ '{Shop : "Shopename", email : "email@gmail.com", name : "name"},{Shop : "Shopename2", email : "email2@gmail.com", name : "name2"}'];

tried replace on data2exportforexcel .but says its not a function.

I am getting data dynamically to data variable for exporting it to excel in node js mongodb using mongoxls plugin

1 answer

  • answered 2018-01-14 10:51 Amirali Ameri

    Did you try this?

    var data2exportforexcel = [JSON.parse(data)];