Whether the server is up
GET
/api/health
const url = 'http://localhost:3000/api/health';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url http://localhost:3000/api/health200 { ok: true } when the server answers and reaches its database within a second, else 503 { ok: false }: for a load balancer’s readiness check, or a smoke test after a deploy. Never cached; it says nothing about what the server holds.
Responses
Section titled “Responses”Up
The database didn’t answer within a second