Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 when resource on server not found #7

Open
joa-queen opened this issue Aug 14, 2015 · 2 comments
Open

404 when resource on server not found #7

joa-queen opened this issue Aug 14, 2015 · 2 comments

Comments

@joa-queen
Copy link

Hi, I got this fetchData method in my component:

fetchData(params, cb) {
            superagent
                .get(`${API_URL}/users/` + params.username)
                .accept('json')
                .set('Api', 'v1')
                .end(function(err, res) {
                        cb(err, res && res.body);
                })
        },

How can I display a 404 message when the superagent returns a 404 from request?

Thanks.

@fraserxu
Copy link

404 is not catch here and it's not an error, you can check the res object and see the http status code, and then you can do whatever you want with it.

@joa-queen
Copy link
Author

But since I'm into fetchData I need to return the cb, don't I?

Sorry if I am too lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants