Response
metro.response
metro.response(...options) : ResponseReturns a new response, built out of the options passed. Later option values override earlier values.
Unlike the normal Response, you can set all available properties for a response, except ok. That is automatically derived from the status code.
You can set the body to any supported type, or to a plain Object. The body will still report as a ReadableStream, but now you can access response.data, which will be the object passed as the body parameter. e.g:
const res = metro.response({
status: 200,
statusText: 'OK',
body: {
foo: 'some data'
}
})
const data = res.data.fooCreating responses from scratch is not usually needed, except when creating mock responses for testing or when enhancing responses in a middleware component. In that case the with() comes in handy.