我正在尝试从保存在根文件夹中的json文件读取数据,这是我得到的错误:
未捕获(承诺)语法错误:JSON.parse:预期属性名称或JSON数据第2行第2列的'}'
代码是:
function getData(){
fetch("./data.json")
.then(response => {
return response.json();
})
.then(data => {
console.log(data);
})
.catch(error => {
console.log(error);
})
}
getData();