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?

Bob Gilmore
  • 12,608
  • 13
  • 46
  • 53
Magedev12345
  • 39
  • 2
  • 3

2 Answers2

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.

njachowski
  • 927
  • 5
  • 14
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.

aliasm2k
  • 883
  • 6
  • 12