Fetch data with parameters from async thunk

habdullahjaved

Abdullah Javed

Posted on July 6, 2024

Fetch data with parameters from async thunk

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);
}
Enter fullscreen mode Exit fullscreen mode

}
);

💖 💪 🙅 🚩
habdullahjaved
Abdullah Javed

Posted on July 6, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related