Closed vincentschroeder closed 8 years ago
I want to handle an rejection of the VideoStore e.g. when the API is not reachable. Unfortunately I don't get the Promise I try to reject when I use VideoStore.fetchVideoById which is defined via decorators in my VideoStore. How can I handle this?
Fetching:
VideoStore.fetchVideoById(videoId).then((res) =>{ }).catch((err)=>{ });
VideoSource:
const VideoSource = { fetchVideoById: { remote(state, videoId) { return fetch(`/videos/${videoId}`).then((response) => { console.log(response.ok); if(response.ok){ return response.json(); }else{ return Promise.reject('no video available.'); } }); }, success: VideoActions.fetchVideoByIdSuccess, error: VideoActions.fetchVideoByIdError } }; export default VideoSource;
Can you handle it in the error action?
Don't use a decorator?
Your first example looks fine.
I want to handle an rejection of the VideoStore e.g. when the API is not reachable. Unfortunately I don't get the Promise I try to reject when I use VideoStore.fetchVideoById which is defined via decorators in my VideoStore. How can I handle this?
Fetching:
VideoSource: