Skip to main content

ApiInstance

view on npm

An API instance is used to make requests to a server. Interact with this by using api()

.headers ⇒ Record.<string, string>

Get the headers for the request

Returns: Record.<string, string>

The headers for the request

.config ⇒ Record.<string, any>

The configuration of this api

Returns: Record.<string, any>

The configuration of this api

.get(path, query)

Send a get request

ParamTypeDescription
pathstring

The url to send the request to

queryRecord.<string, any>

The url query to send

.post(path, body) ⇒ Promise.<PlexusApiRes.<unknown>>

Send a post request

Returns: Promise.<PlexusApiRes.<unknown>>

The response from the server

ParamTypeDescription
pathstring

The url to send the request to

bodyRecord.<string, any> | string

The body of the request (can be a string or object)

.put(path, body) ⇒ Promise.<PlexusApiRes.<unknown>>

Send a put request

Returns: Promise.<PlexusApiRes.<unknown>>

The response from the server

ParamTypeDescription
pathstring

The url to send the request to

bodyRecord.<string, any> | string

The body of the request (can be a string or object)

.delete(path) ⇒ Promise.<PlexusApiRes.<unknown>>

Send a delete request

Returns: Promise.<PlexusApiRes.<unknown>>

The response from the server

ParamTypeDescription
pathstring

The url to send the request to

.patch(path, body) ⇒ Promise.<PlexusApiRes.<unknown>>

Send a patch request

Returns: Promise.<PlexusApiRes.<unknown>>

The response from the server

ParamTypeDescription
pathstring

The url to send the request to

bodyRecord.<string, any> | string

The body of the request (can be a string or object)

.gql(query, variables) ⇒ Promise.<PlexusApiRes.<unknown>>

Send a graphql request

Returns: Promise.<PlexusApiRes.<unknown>>

The response from the server

ParamTypeDescription
querystring

The gql query to send

variablesRecord.<string, any>

Variables

.auth(type, token) ⇒ this

Set the authentication details for the request

Returns: this

The current instance

ParamTypeDescription
type'bearer' | 'basic' | 'jwt'

optional - The type of authentication to use. This determines what prefix to use for the header

tokenstring

The token to use for authentication

.reset() ⇒ this

Reset this routes configuration

Returns: this

The current instance