I do have a question, how do you define the response body interface if you want to return either an error response or a true response. Example below:
rest.get<TodoId>(`${apiUrl}/todo`,async(req,res,ctx)=>{const{todoId}=req.bodyconsttodo=awaittodosDB.read(todoId)if(!todo){returnres(ctx.status(404),ctx.json({status:404,message:'Todo not found'}),)}returnres(ctx.json({todo}))}),
Hello Artem, great article, and thank you.
I do have a question, how do you define the response body interface if you want to return either an error response or a true response. Example below:
Thank you very much
Thank you, Fakorede.
With the current implementation you'd have to use a union type to define such response:
Great. Thanks for your response