我使用的是json-server,我可以发布并获取。但我无法进行更新。Json服务器更新
在我的数据库,我有这样的数据:
{
"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”。 – Luxor001