Fetch data with parameters from async thunk

RMAG news

Want to fetch data by parameters unable to fetch why ??

export const getdataById = createAsyncThunk(
“bus/getdataById”,
async (data, { rejectWithValue }) => {
try {
const response = await axios.get(${API_Link}getdatabyId, {
params:{
id: data.id,
},
headers: {
“Content-Type”: “application/json”,
Accept: “application/json”,
},

},data.id);
return response.data;
} catch (error) {
return rejectWithValue(error.response.data.message || error.message);
}

}
);

Please follow and like us:
Pin Share