Hello everyone .we are working an application.After saving a new listing (post request) i want to go to another page.I am using redux .After action , i want to go to another page .Here is the some part of the link.Please let me know how can i solve this.
const res = await fetch(`${SERVER_URL}/lists/add`, {
method: 'POST',
body: fd
});
/**
* nature of Request and response status check.
*/
if (res.status === 200) {
const list = await res.json();
toast.success('🎉 Your place has been added!');
toast.success('🎉 You are redirecting to preview your new listing!');
dispatch({
type: ADD_LIST_SUCCESS,
payload:list
})
.then(()=>{
history.push("listings") //Here I want to Go to Listing Page .
})
} else {
toast.error(' ⛔️ Some error has been occurred!!');
dispatch({
type: ADD_LIST_ERROR,
payload: 'Some problem occurred'
});
}
} catch (err) {
console.log(err)
toast.error(' ⛔️ Some error occured!');
dispatch({
type: ADD_LIST_ERROR,
payload: err
});
}
})();