fetch( )

Retrieves the specified resource from the network using HTTPS.

The fetch() function fetches an HTTPS resource from the network. It returns a Promise that resolves to a WixFetchResponse object representing the HTTP response to the request.

Responses with an HTTP status code in the ranges 2xx, 4xx, and 5xx are considered fulfilled. Use the httpResponse.ok property to confirm that the HTTP request was successful with a response code in the 2xx range.

The optional WixFetchRequest object contains information about an HTTPS request. Additional functionality is available in each of the respective Fetch API implementations.

Notes: Some common errors when using the fetch() function are described here along with possible solutions.

  • You can usually tell if you are experiencing these issues by checking your browser's console using the browser's developer tools.
  • Certain CORS (Cross-Origin Resource Sharing) requests are restricted when originating from a browser. Usually, GET requests and certain POST requests can be made from your site's Public, Page, or Site code. All other requests need to be made from your site's Backend code. If you are experiencing an issue with a fetch() call due to a CORS restriction, move the fetch() call to the backend as described in Accessing 3rd-Party Services.
  • Because all Wix sites use HTTPS, you can't request HTTP content from a service in your site's code.
Method Declaration
Method Parameters

The url of the resource to fetch.


Options for the fetch operation.

Return Type:Promise<WixFetchResponse>
Was this helpful?