Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Customize shopware-6-client to add new API call #1804

Answered by niklaswolf
sourin00 asked this question in Q&A
Discussion options

You must be logged in to vote

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.

import { getApplicationContext} from "@shopware-pwa/composables"
...
const { apiInstance } = getApplicationContext({
    contextName: "YourOwnContextName"
})
...
async function makeApiCall (){
    const response = await apiInstance.invoke.post(API_ENDPOINT, params)
}

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…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sourin00
Comment options

Answer selected by sourin00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants