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")
     }

Related Query

More Query from same tag