我有一个Deployed API,它公开了这样的json结构:
[
{id: "1"
username: "john",
password: " ..... ",
email: "example@gmail.com",
coins: 60,
badges: [ ],
courses:[
{ id: "123456",
title: "Animals",
grades_per_module: [ [30], [28, 26], [25, 24]]
.....
},
{ id: "112233",
title: "Food",
grades_per_module: [ [20, 25, 27], [22]]
.....
}
]
},
{id: "2"
username: "mark",
password: " ..... ",
email: "ex@gmail.com",
coins: 40,
badges: [ ],
courses:[
{ id: "123456",
title: "Animals",
grades_per_module: [ [27], [21, 30], [30, 30]]
.....
}
]
}
]
然后,我需要使用角度代码删除用户“ john”的id =“ 112233”的实习课程。
所以我使用了这段代码,但是它不起作用:
this.http.put('http://localhost:2403/users/1',
{ "courses": { $pull: { "id": 112233 } }
}).subscribe( ..... )
已部署的API向我返回了肯定的消息,但是该课程并未真正从用户对象中删除。 谁能帮我吗?