Im trying to get data that requires request body and am having trouble. With other post requests, {requestedThings} worked fine but with get request, it gives me an error
Can someone help me how to fix this ?
async function initSurvey(userNo: number) {
return await loginApi.get(`/user/survey`, { userNo: userNo });
}
I am getting below message :
TS2345: Argument of type ‘{ userNo: number; }’ is not assignable to parameter of type ‘AxiosRequestConfig’.
Object literal may only specify known properties, and ‘userNo’ does not exist in type ‘AxiosRequestConfig’.
46 | async function initSurvey(userNo: number) {
47 | return await loginApi.get(
/user/survey, { userNo: userNo });
| ^^^^^^^^^^^^^^
48 | }
49 |
50 | export {
>Solution :
get request method does not have request body according to MDN specs. If you are using axios you should do as described below or send request without body according to your loginApi API.
await axios.get('/user/survey', {
params: {
userNo
}
)
