export const addTeamReview = createAsyncThunk(
"team/addTeamReview",
async (teamId, comment, { getState }) => {
const {
userLogin: { userInfo },
} = getState();
try {
await axios.post(`/api/teams/${teamId}/review`, comment, {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${userInfo.token}`,
},
});
} catch (error) {
console.log(error);
}
}
);
在这段代码中,我不能将
{getState}
作为第二个参数。当我们有多个参数时,我不知道该怎么办
我尝试将 getState 放在第二位,将评论对象放在第三位……但它不起作用。 另外,我尝试在一个对象中同时传递 teamId 和 comment ..那也行不通