Skip to content

Feature request: dispatch an _ERROR action if there was an API error #17

@shankie-codes

Description

@shankie-codes

You're going to love me @mikestead .

When I've used Redux before, one of the starters that I used had a really nice model, that was, when making AJAX requests, to dispatch _REQUEST, _SUCCESS and _FAILURE actions depending on what happened in the api service. Originally I thought that this was daft, but actually, you want to be able to handle errors in different kinds of requests differently.

It looks like it should be a pretty easy change as you'll just have to add a .catch() on the dispatch around here – and dispatch a new action, such MY_ACTION_NAME_ERROR. If I'm not mistaken, makeFetchRequest already returns a fetch promise, which should already reject if there's an error, which means that there shouldn't be too much working through the entire codebase.

Are my assumptions above correct? If so, would you accept a PR for that?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions