Papupata Documentation

API Reference

class DeclaredAPI

exposed type CallArgsType

Purpose

Represents the type of arguments to API invocation. This exists to help you create functions that return parts or all of a requests's parameters.

Usage

The exposed types are used with the typeof operator. See the example below for details.

Although the types are presented as fields on the API, they have no runtime value.

Examples

Older styles are still supported in later versions, just not preferred.
Basic usage
import { APIDeclaration } from 'papupata'
const api = new APIDeclaration()
const myAPI = api.declarePostAPI('/do-stuff')
  .query({q: String}})
  .body<{key: string}>
  .response<string>()

type CallArgsType = typeof myAPI['CallArgsType']
// CallArgsType is now {key: string, q: string}
Practical usage
await myAPI(getRequestParams())

function getRequestParams(): typeof myAPI['CallArgsType']  {
  // Now typescript will complain because we do not return everything it needs
}