JSON from EJS to JSON object in JS

后端 未结 1 1033
粉色の甜心
粉色の甜心 2021-02-15 13:06

I am using EJS with Node.JS, and am passing a JSON object into it, but need to have access to it as a usable object in the page. I am getting the unexpected token o error from t

相关标签:
1条回答
  • 2021-02-15 13:27

    try this:

    var initData = JSON.parse('<%-JSON.stringify(list)%>');
    

    OR:

    var initData = <%-JSON.stringify(list)%>;
    
    0 讨论(0)
提交回复
热议问题