What is the best way to type an API Response

I'm currently trying to type my API Response for a user login what would be the best way to type that response that could take either a 404 error or a successful ok response.

This is somewhat correct but forces me to ensure that data is not null, but this doesn't seem like the correct approach when typing this response type. Is there a different way I can approach this by combining an error type and an ok type?
CleanShot_2023-02-15_at_23.23.41.png
Was this page helpful?