Refine cannot detect my backend PUT endpoint
I was following the JavaScript mastery tutorial on refine. The get, post and delete endpoints are working perfectly except for the put route which seems like it can be reached by refine. Instead of giving me an error about PUT. It returns an error saying cannot PATCH.. kindly help me solve this
5 Replies
Hi @generalfib. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It seems like you're using the default
update
function provided by the data provider, which uses the PATCH
HTTP method. To change it to PUT
, you can override the update
function in your data provider. Here's an example of how to do this with the @refinedev/simple-rest
data provider:
This code snippet overrides the update
function to use the PUT
method instead of PATCH
. Replace "API_URL"
with your actual API URL and use myDataProvider
as the data provider for your Refine app.
Source: refine.dev/docs/api-reference/core/providers/data-provider (https://refine.dev/docs/api-reference/core/providers/data-provider)
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------Data Provider | refine
The data provider acts as a data layer for your app that makes the HTTP requests and encapsulates how the data is retrieved. refine consumes these methods via data hooks.
<@887715810599137300> kapa.ai is still learning and improving, please let us how it did by reacting below
fascinating-indigo•2y ago
Hey @generalfib,
Also, you can use
meta.method
to change HTTP method. You can find more information here: https://refine.dev/docs/packages/documentation/data-providers/simple-rest/#default-http-methods-and-customizing-themratty-blushOP•2y ago
Thanks it really helped me