【发布时间】:2016-08-11 11:37:25
【问题描述】:
我正在使用json-server,我可以发布和获取。但我无法进行更新。
在我的数据库中,我有以下数据:
{
"userRecipes": [
{
"id": 1,
"desc": "dog",
"flag" : true
}
]
}
我希望更新标志,为此我使用了此代码,但它不起作用:
loginDataSend.flag = true;
$http
(
{
method: 'update',
url: 'http://localhost:3000/userRecipes/' + id,
data: loginDataSend,
dataType: "json"
}
).error(funcion()
{
// Error code here
alert("error");
})
.success(function ()
{
alert("ok");
});
感谢您的帮助。
【问题讨论】:
-
尝试使用关键字“put”而不是“update”。