Call an HTTP function that is defined using the get
prefix. For example, get_myFunction()
.
Learn more about get()
HTTP functions.
function get(functionName: string, options: getMethodOptions): Promise<getMethodResponse>;
Name | Type | Description |
---|---|---|
functionName | string required | Name of your site's HTTP function to call without its method prefix. For example, for get_myFunction() , use myFunction . |
options | object | All properties of the options object are required as defined by your site's HTTP function. |
options
PropertiesName | Type |
---|---|
headers | Supported types:
|
params | URLSearchParams object. |
The response object from the site’s HTTP function.
import { OAuthStrategy, createClient } from "@wix/sdk";
import { functions } from '@wix/http-functions';
const client = createClient({
auth: OAuthStrategy({ clientId: "MY_CLIENT_ID" }),
modules: { functions },
});
async function callMyHttpFunction() {
const response = await client.functions.get('myHttpFunction', options);
}
import { ApiKeyStrategy, createClient } from "@wix/sdk";
import { functions } from '@wix/http-functions';
const client = createClient({
auth: ApiKeyStrategy({
siteId: "MY-SITE-ID",
apiKey: "MY-API-KEY",
}),
modules: { functions },
});
async function callMyHttpFunction() {
const response = await client.functions.get('myHttpFunction', options);
}