HttpClient
to use it in our JavaScript plugin. We also create a new instance of the HttpClient
and assigned it to a variable in our ExamplePlugin
.get
method of the HttpClient
to invoke a get request.get
method takes three arguments. The first one is the url
which we want to call. In the example we are going to fetch a widget which contains some HTML. The second parameter is a callback
function. It will be invoked when the API call was done. In the example below we pass in the handleData
method of our plugin. The callback function then receives the response
of the API call. We can now use this in our plugin to display the widget in the DOM, for example.get
method is the contentType
which will be sent in the request header of the API call. It is optional and by default set to be application/json
.StoreApiClient
which automatically injects the correct credentials, so you can make calls from the Storefront to the Store API.HttpClient
: