0

I have written a REST API in nodejs.

I want to send HTTP status codes on various events.

For example when data is returned I send HTTP code 200.

What is the status code to return when the input data is missing?

2 Answers 2

4

This isn't specific to nodejs. HTTP status codes are general -- you can read about them on wikipedia:

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

I think you want client error code 400, which means Bad Request.

Sign up to request clarification or add additional context in comments.

Comments

0

Perhaps you should return 404, not found. As mentioned in previous answer, HTTP status codes are general.

A tip: try getting grip on HTTP before starting off web development.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.