#Data fetch from custom endpoints
9 messages · Page 1 of 1 (latest)
You can just use native fetch with your endpoint.
You can also use useQuery from tanstack query to make it easier with loading states client side.
https://github.com/medusajs/admin/blob/main/src/services/request.js
Kind of did a bit of modified version of what's in Admin
And it's not working?
It is, all good. Was hoping that there is a way to use Medusa.client
No, it's not possible currently to use medusa js client for custom endpoints
There is some way to use it. You can extend the client for example and instanciate it. In the extended class you can add your resources. It is just a class in the end.
Or you can spread it and add your method which is a bit more dirty like I did here https://github.com/adrien2p/medusa-plugins/blob/main/packages/medusa-plugin-sentry-ui/src/utils/index.ts
But it was a quick poc and did it quick and dirty but i would rather extend it in a real project