httpClient

The httpClient submodule includes helper methods for making HTTP requests within the Wix platform.

Import statement

Copy

Methods

fetchWithAuth()

Makes HTTP requests to Wix REST APIs and endpoints that require a Wix access token, such as endpoints hosted by a Wix app backend. The Wix development framework generates the access token. The token reflects the identity of the current site user and is automatically included in requests from this method as an Authorization header.

Notes:

  • This method is only intended for use with Wix-hosted apps.
  • Only use this method to call a Wix REST API if the needed functionality isn't available in the SDK. Otherwise, use the SDK version.

Method Declaration

Copy

Parameters

NameTypeDescription
urlstringURL of the REST API to call.
optionsobjectStandard fetch request options.

Returns

Standard fetch() response.

Example

Call the List Published Site Urls endpoint:

Copy

graphql()

Calls Wix APIs through the Wix GraphQL API.

Supports queries and mutation.

Important:

The Wix GraphQL API is in Alpha and is subject to change.

Method Declaration

Copy

Parameters

NameTypeDescription
queryTypedQueryInput<Result, Variables>Wix GraphQL query to execute.
variablesobjectVariables to use in the query. Optional.

Returns

NameTypeDescription
dataobjectResult of the query. The format of the data depends on the query.
errorsobjectGraphQL query errors. This property is not returned if there are no errors.

Example

Query products using graphQL:

Copy
Did this help?