question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best way to return JSON for 404 etc

See original GitHub issue

Informations

Type Version
Question 4.x

Description

Express default error handling responds with the below.

Cannot GET /

I want to convert this to a JSON response but I am unable to add a errorHandler in the ServerLoader-$afterRoutesInit. Can you please advise?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Romakitacommented, Sep 9, 2018

Hello I’ve added a working example on the website: http://tsed.io/tutorials/not-found-page.html

See you, Romain

1reaction
Romakitacommented, Mar 26, 2020

Yes sir 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best way to return JSON for 404 etc · Issue #433 · tsedio/tsed
To customize 404, we just have to register a new middleware on $afterRouteInit (or $onServerReady) hook. $afterRoutesInit in the ts.ed lifecycle ...
Read more >
How do I return json for 404s and 403s in WebAPI?
Open Visual Studio 2013 Update 4 · New Project · Choose . · Choose Templates > Visual C# > Web > ASP.NET Web...
Read more >
Return json response for only API 404 error - Laracasts
I have exposed the API of a laravel 5.7 application. My goal is to return json response for all API calls that results...
Read more >
HTTP status and error codes for JSON | Cloud Storage
Error responses usually include a JSON document in the response body, ... Example values include: 400 (Bad Request), 401 (Unauthorized), and 404 (Not...
Read more >
Problem Details - The right way to specify errors in Web API ...
For the 404 wherein the route didn't match, there isn't much you can do, but for scenarios where you want to return "Not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found