score:1
Accepted answer
this is pretty much the correct way - fetch does not throw
on a non-2xx-status code.
tics can change a bit - you would usually either throw or return rejectwithvalue:
if (!response.ok) {
throw new error("response was not ok")
}
or
if (!response.ok) {
return thunkapi.rejectwithvalue("response was not okay")
}
Source: stackoverflow.com
Related Query
- How to show reject message with createAsyncThunk?
- useEffect to show snackbar if message is not null, and how to use useState with that?
- With the React Rating Component, how to show a custom message based on the rating?
- How to handle axios errors and show modal with error message
- how to validate username minlength and show error message with react hooks
- ReactJs how to show list with load more option
- React Flash Message: How to make the message show without refreshing the page but refresh on 200
- How to create a show more/less button with ReactJS to adjust the size of a div?
- How to redirect with flash message react-router 4
- How to show an alert with errors found after submitting Formik form in react native
- How to show dynamic tabs with react-native-tab-view?
- how to show error message in react js when http request send?
- How to redirect with react-router and send a message
- How do I hide and show components with useState or conditional rendering in React?
- How do I show the Google passport oAuth consent screen in the react frontend, not with express views template
- How to validate password and confirm password in react hook form? Is there any validate property and message in react hook form to show errors?
- How to show Form error summary using Formik with yup validationSchema
- How to show NoOptionsText only with condition in MaterialUI Autocomplete
- How do i annotate React.forwardRef with jsdoc comments so that intellisense can show up for the underlying component?
- How to format a number to percentage with two decimals using FormatJs Message Syntax?
- ReactStrap modal close icon is not getting show in the modal and How to use the header with some another tag
- How to show Downshift suggestion inside Dialog with Material UI?
- react-hook-form: how to show validaton message after getting response from api end point?
- How do I programatically show "ripple effect" with MUI?
- How to show server (Java) Exception message in React.js
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- How do I show which item in the Menu List is selected with Material UI React?
- React: How to show message when result is zero in react
- React : How to Show Message if there is no records
- How can I display my API response message on my frontend UI with React?
More Query from same tag
- Separately called React setState() giving unexpected result
- how do you find app bar height in react material ui app?
- Cannot set property 'x' of undefined
- React redux - change property on individual state item
- I want to display div tags according to the type of Props value
- Mobile browser positions elements as if the view is 360px wide, but renders images on the page at a higher resolution. How does this work?
- ag-grid + react: checkboxSelection does not update state
- React tests with jest, enzyme behave strangely
- react-chartjs-2 options are not recognized for Bars
- How to pass all children elements of parent component?
- Jest with Enzyme, why is `toHaveBeenCalled` not triggering in my React Component test?
- Connect express backend to React frontend (in the same server if possible)
- Laravel React relation one to many
- A good way to handle @material-ui Skeleton scaling within a variable height grid row?
- Binding element 'posts' implicitly has an 'any' type
- How to delay the return() of React functional component
- html flag in reactjs render method
- How to make a badge appear right next to Card Title in Material UI
- Grid lines in d3 js don't match the axes
- How do I get the previous value of a field in React? I want to use it to display the user's previous input when they click 'edit' on the field
- How to downgrade react-router-dom version to v5.2.0
- React - How to clear the value of a React-Select when another React-Select changes
- How should one go about making a microservice out of a reactjs module?
- Remove Item on click in React
- How to add select input in fullCalendar header?
- Donut Chart : Trigger legend or pie click event while selecting outside filter state change
- How to push a button on sticky navigation after scrolling down a bit?
- How do you swap a component with another after onclick event?
- How to create a generic interface or type that accepts tow different interfaces that go under single array?
- I downloaded a zip and extracted the files but I can't run it using npm start : reactj.s