Class: ConvexHttpClient<API>
browser.ConvexHttpClient
A Convex client that runs queries and mutations over HTTP.
This is appropriate for server-side code (like Netlify Lambdas) or non-reactive webapps.
If you're building a React app, consider using ConvexReactClient instead.
Type parameters
Name | Type |
---|---|
API | extends GenericAPI |
Constructors
constructor
• new ConvexHttpClient<API
>(address
)
Type parameters
Name | Type |
---|---|
API | extends GenericAPI |
Parameters
Name | Type |
---|---|
address | string |
Methods
backendUrl
▸ backendUrl(): string
Obtain the ConvexHttpClient's URL to its backend.
Returns
string
The URL to the Convex backend, including the client's API version.
setAuth
▸ setAuth(value
): void
Set the authentication token to be used for subsequent queries and mutations.
Should be called whenever the token changes (i.e. due to expiration and refresh).
Parameters
Name | Type | Description |
---|---|---|
value | string | JWT-encoded OpenID Connect identity token. |
Returns
void
clearAuth
▸ clearAuth(): void
Clear the current authentication token if set.
Returns
void
query
▸ query<Name
>(name
): (...args
: Parameters
<NamedQuery
<API
, Name
>>) => Promise
<ReturnType
<NamedQuery
<API
, Name
>>>
Construct a new Query.
Type parameters
Name | Type |
---|---|
Name | extends string |
Parameters
Name | Type | Description |
---|---|---|
name | Name | The name of the query function. |
Returns
fn
The Query object with that name.
▸ (...args
): Promise
<ReturnType
<NamedQuery
<API
, Name
>>>
Parameters
Name | Type |
---|---|
...args | Parameters <NamedQuery <API , Name >> |
Returns
Promise
<ReturnType
<NamedQuery
<API
, Name
>>>
mutation
▸ mutation<Name
>(name
): (...args
: Parameters
<NamedMutation
<API
, Name
>>) => Promise
<ReturnType
<NamedMutation
<API
, Name
>>>
Construct a new Mutation.
Type parameters
Name | Type |
---|---|
Name | extends string |
Parameters
Name | Type | Description |
---|---|---|
name | Name | The name of the mutation function. |
Returns
fn
The Mutation object with that name.
▸ (...args
): Promise
<ReturnType
<NamedMutation
<API
, Name
>>>
Parameters
Name | Type |
---|---|
...args | Parameters <NamedMutation <API , Name >> |
Returns
Promise
<ReturnType
<NamedMutation
<API
, Name
>>>
action
▸ action<Name
>(name
): (...args
: Parameters
<NamedAction
<API
, Name
>>) => Promise
<ReturnType
<NamedAction
<API
, Name
>>>
Construct a new Action.
Type parameters
Name | Type |
---|---|
Name | extends string |
Parameters
Name | Type | Description |
---|---|---|
name | Name | The name of the action. |
Returns
fn
The Action object with that name.
▸ (...args
): Promise
<ReturnType
<NamedAction
<API
, Name
>>>
Parameters
Name | Type |
---|---|
...args | Parameters <NamedAction <API , Name >> |
Returns
Promise
<ReturnType
<NamedAction
<API
, Name
>>>