A
Alokai10mo ago
Caroline

How to extension api for VSF

I was added extension on middleware.config.js like: integrations: { magento: { location: '@vue-storefront/magento-api/server', extensions: (extensions) => [ ...extensions, { name: 'extension-name', extendApiMethods: { customMethod: async (context, params) => { const response = await context.client.mutate({ mutation: gql${CUSTOMER_METHOD}, variables, fetchPolicy: 'no-cache', context: { req: context.req, res: context.res } }); } } } ], }, }, then I was called the customMethod on .vue file, like: import { useVSFContext, onSSR } from '@vue-storefront/core'; export default { setup() { const { $magento} = useVSFContext(); onSSR(async () => { await $magento.api.customMethod({ query: 'test', limit: 20 }) }); } } But when I console.log($magento), the $magento is undefined. I don't know why the $magento is undefined.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server