#Data fetch from custom endpoints

9 messages · Page 1 of 1 (latest)

zealous swift
#

Any examples or tutorials on how to send requests to custom endpoints?
I have created endpoint from where I can get top products from the last month. Was looking over source code and saw that medusa-js Medusa has client property but it's private.

primal mirage
#

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.

zealous swift
primal mirage
#

And it's not working?

zealous swift
primal mirage
#

No, it's not possible currently to use medusa js client for custom endpoints

ionic mauve
#

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.

#

But it was a quick poc and did it quick and dirty but i would rather extend it in a real project