在一个 Vue 项目中,我挂载了一个 JSON 文件,它与 URI 一起工作。我用数据。我正在尝试修补数据,但是当我尝试修补 handleCurrent 函数中的文件时,我终生无法解决 404 not found 错误。
export default {
name: "Home",
data() {
return {
entries: [],
uri: "[CORRECT LINK]",
};
},
mounted() {
fetch(this.uri)
.then((res) => res.json())
.then((data) => (this.entries = data))
.catch((err) => console.log(err.message));
},
methods: {
handleCurrent(id) {
let currentCurrent = this.entries.filter((entry) => {
return entry.label === "current";
});
currentCurrent.forEach((entry) => {
entry.label = "none";
});
let newCurrent = this.entries.find((entry) => {
return entry.id === id;
});
newCurrent.label = "current";
fetch(this.uri, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ deck: "current" }),
}).catch((err) => console.log(err.message));
},
},