I am having trouble understanding in how will the payload look in the first action. Why in the first one there is { } and ...
, what does that give? How do I pass data into it, when I call it from a component?
In the second one, i would just pass an object, but I don’t get the first one.
JavaScript
x
4
1
update({ id, rest }) {
2
return http.patch(`/test/${id}`, rest);
3
},
4
JavaScript
1
4
1
update(id, rest) {
2
return http.patch(`/test/${id}`, rest);
3
},
4
Advertisement
Answer
call update
like this.
JavaScript
1
8
1
update({
2
id: 123,
3
4
// other property
5
name: 'your name',
6
tel: 'your tel'
7
})
8
in update
, id
is123
, and rest
is {name: 'your name',tel: 'your tel'}
JavaScript
1
12
12
1
function update ({ id, rest }) {
2
console.log('id is:', id);
3
console.log('rest is:', rest);
4
}
5
6
update({
7
id: 123,
8
9
// other property
10
name: 'your name',
11
tel: 'your tel'
12
});