Customize shopware-6-client to add new API call #1804
-
Customize shopware-6-client to add new API callHi, How can I customize/override/extend a service from the shopware-6-client(API client) to have my own implementation which I can use in a composable ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, import { getApplicationContext} from "@shopware-pwa/composables"
...
const { apiInstance } = getApplicationContext({
contextName: "YourOwnContextName"
})
...
async function makeApiCall (){
const response = await apiInstance.invoke.post(API_ENDPOINT, params)
}
I hope this helped :) |
Beta Was this translation helpful? Give feedback.
Hey,
if I understand your question correctly, you want to do a new API call from a new composable you're creating. For this, you actually don't need to extend the shopware-6-client, but rather use its functionality.
apiInstance
will be a instance from shopware-6-client, so you don't need to worry about authentication and the session-context and so on.apiInstance.invoke.post
will be essentially the post-function from axios, s…