abstract-purpleA
Refine3y ago
4 replies
abstract-purple

How can I send an attribute other than data to the request in "onFinish"?(ant.design, strapi v4)

I want to upload file(strapi v4 mediatype).
Strapi V4 Example
    //https://docs.strapi.io/developer-docs/latest/plugins/upload.html#examples

    const formData = new FormData();
  
    formData.append('data', JSON.stringify(data));
    formData.append('files.entryName', file);


Refine(Ant Design) Example
  onFinish({
    attribute1: "..."
    attribute2: "..."
    file.entryName: FileObj
  })  


// https://refine.dev/docs/api-reference/antd/hooks/form/useForm/#how-can-i-change-the-form-data-before-submitting-it-to-the-api

//  request result
//  data : {
//    attribute1: 'value1',
//    attribute2: 'value2',
//    file.entryName: FileObj
// }
//
//  request result i want
//  data : {
//    attribute1: 'value1',
//    attribute2: 'value2',
//  }
//  file.entryName: FileObj
//
Was this page helpful?