Parsing failed after axios successfully read the local json file.

parsing failed after axios successfully read the local json file

export function getEmojiData() {
  return axios({
      method: "get",
      url: "/static/emojiDB.json",
      responseType:"json",
      // transformRequest: [function (data, headers) {
      //   // Do whatever you want to transform the data

      //   return JSON.stringify(data);
      // }],
    })
    .then(function(res) {
      return Promise.resolve(res.data);
    });
}

   getEmojiData().then((res)=>{
       console.log(typeof res)
       console.log(res);
       console.log(JSON.parse(res))
       })

Mar.02,2021

in JSON data, only " (double quotes) is allowed, and ' (single quotes)!
error message is also obvious. You can replace all single quotes in local json files with double quotes (note in English)


<
Menu