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.9 Replies
@Caroline Are you resolve it ?
I have a quick question I've been trying to get answered for weeks does it still make sense to do a vue storefront setup with magento 2 if you don't plan on using the paid version?
I think you don't should
@addff No, it does not make sense anymore. Unless you go enterprise, there might be better options available.
This project and support once was very awesome.
Now it is very enterprise focused and with most of your challenges and questions you would be alone.
@Siber thanks for letting me know. Anything you would recommend?
@addff It depends a lot on the requirements, skill level of the team, budget etc.
But I recommend researching Adobe PWA Studio and also ScandiPWA.
Ok thanks I'll look into them also have you heard of Medusa.js?
Nope. Did look into it and seems very interesting. 🙂
Who’s ready to escape from working from 9-5? How will you feel living a luxury lifestyle without depending on your family or parent ? Why can’t you retire yourself being in poverty zone and retire your parents as well
Just hit me up with “I’m ready