Echo JS 0.11.0

<~>

tracker1 1906 days ago. link 1 point
If you're wrapping the response from fetch for an error, I would suggest using 

    throw Object.assign(new Error("Fetch Error"), { response });

This gives you the full context instead of response.toString() as the error message.

Something I do in practice for my API endpoints is always return {result} or {error} from my API.  An object where a root error can be checked against, or the result... This way I can have a very consistent handler, which is usually a wrapper around fetch as I'm not currently supporting any non-green browsers and fetch has been around for long enough now.