Possible to return a response in Express 5?

I’ve read #2259 there a single example of a route using Promises? I’ve read the router changelogs etc, from alpha 2 to alpha 7, but I can’t find anything.

I know, eg, https://arc.codes lets me just return a response. It also has middleware that uses this pattern.

exports.handler = async function http(request) {
  return {
    status: 201,
    type: 'text/html; charset=utf8',
    body: `
      <!doctype html>
      <html>
        <body>hello world</body>
      </html>
   `
  }
}

Does express 5 allow me to return a response from a route?

Author: Fantashit

1 thought on “Possible to return a response in Express 5?

  1. Hi! We are still working on docs and such, so don’t have anything to point to yet.

    Does express 5 allow me to return a response from a route?

    At least, not like in your example. The API for sending responses is the same as Express 4.

    Middleware and handlers can now return promises and if the promise is rejected, next(err) will be called with err being the value of the rejection. The resolved value of the promise is ignored.

Comments are closed.