How do I sent REST request with useForm from refinedev/antd
In meta property there is only attribute for gqlMutation and gqlQuery
useForm hook from the Ant Design integration allows you to pass additional information to data provider methods using the meta property. This can be used for various purposes such as customizing the data provider methods for specific use cases, generating GraphQL queries using plain JavaScript Objects (JSON), and providing additional parameters to the redirection path after the form is submitted.meta property to pass headers or other additional information to your data provider methods. In the following example, the headers property is passed in the meta object to the create method:meta object is used to pass the headers property to the create method of the data provider. The httpClient.post method is then used to send a POST request to the specified URL with the provided headers.posts) and a GraphQL data provider for another (like users). posts resource will use the REST data provider and users resource will use the GraphQL data provider.httpClient.postuseForm({
meta: {
headers: { "x-meta-data": "true" },
},
});
const myDataProvider = {
//...
create: async ({ resource, variables, meta }) => {
const headers = meta?.headers ?? {};
const url = `${apiUrl}/${resource}`;
const { data } = await httpClient.post(url, variables, { headers });
return {
data,
};
},
//...
}; import restProvider from "@refinedev/rest";
import graphqlProvider, { GraphQLClient } from "@refinedev/graphql";
const restClient = restProvider("REST_API_URL");
const graphqlClient = new GraphQLClient("GRAPHQL_API_URL");
const dataProvider = {
posts: restClient,
users: graphqlProvider(graphqlClient),
// ... other resources
};
<Refine dataProvider={dataProvider} />;