ApiInstance
An API instance is used to make requests to a server. Interact with this by using api()
- ApiInstance
- .headers ⇒
Record.<string, string>
- .config ⇒
Record.<string, any>
- .get(path, query)
- .post(path, body) ⇒
Promise.<PlexusApiRes.<unknown>>
- .put(path, body) ⇒
Promise.<PlexusApiRes.<unknown>>
- .delete(path) ⇒
Promise.<PlexusApiRes.<unknown>>
- .patch(path, body) ⇒
Promise.<PlexusApiRes.<unknown>>
- .gql(query, variables) ⇒
Promise.<PlexusApiRes.<unknown>>
- .auth(type, token) ⇒
this
- .reset() ⇒
this
- .headers ⇒
.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
Param | Type | Description |
---|---|---|
path | string | The url to send the request to |
query | Record.<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
Param | Type | Description |
---|---|---|
path | string | The url to send the request to |
body | Record.<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
Param | Type | Description |
---|---|---|
path | string | The url to send the request to |
body | Record.<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
Param | Type | Description |
---|---|---|
path | string | 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
Param | Type | Description |
---|---|---|
path | string | The url to send the request to |
body | Record.<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
Param | Type | Description |
---|---|---|
query | string | The gql query to send |
variables | Record.<string, any> | Variables |
.auth(type, token) ⇒ this
Set the authentication details for the request
Returns: this
The current instance
Param | Type | Description |
---|---|---|
type | 'bearer' | 'basic' | 'jwt' | optional - The type of authentication to use. This determines what prefix to use for the header |
token | string | The token to use for authentication |
.reset() ⇒ this
Reset this routes configuration
Returns: this
The current instance