Challenge.fromResponseList
Extract multiple Challenges
Extracts every Payment Challenge from a 402 Response.
Usage
import { } from 'mppx'
const = await ('/resource')
if (. === 402) {
const = .()
}The returned array preserves the order of the Payment Challenges in the WWW-Authenticate header. Quoted parameter values are parsed as data, including values that contain the Payment scheme name.
With method type narrowing
Use method definitions to get type-safe access to method-specific request fields.
import { } from 'mppx'
import { } from 'mppx/tempo'
const = await ('/resource')
if (. === 402) {
const = .(, {
: [.],
})
}Return type
type ReturnType = Challenge[]An ordered array of deserialized Challenges.
Parameters
options (optional)
- Type:
{ methods?: readonly Method.Method[] }
Optional settings to narrow the Challenge types using method intents.
response
- Type:
Response
The HTTP response. Its status must be 402.
Errors
Throws when the response isn't 402, the WWW-Authenticate header is missing, or the header contains no Payment Challenges.