Skip to content

Serialize Response Body

.resolveWith(type)

ParametersDefaultDescription
type"intelligent"how to serialize response body
TypeDescription
"intelligent"Return context.output when it be set. Otherwise, parse response body according Context-Type
"response"Return Response Object
"text"Return context.response.text()
"json"Return context.response.json()
"form-data"Return context.response.formData()
"blob"Return context.response.blob()
"array-buffer"Return context.response.arrayBuffer()

Usage

typescript
import { request } from 'keq'

const res = await request
  .get('/cat')
  .resolveWith('response')

const body = await res.json()

console.log(`Cat name is: ${body.name}`)