Fetch data with parameters from async thunk
Abdullah Javed
Posted on July 6, 2024
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);
}
}
);
💖 💪 🙅 🚩
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.