'imageUploadUrl SunEditor in Next.js

I want to ask because after a few days I haven't found a way to upload files to the API. I use suneditor for editor in my Next.js project. I want that when I upload an image, the image will be sent to the API https://api-my.com/v1/file-uploads or /file-uploads with a field that is file.

I have tried using this method, but it doesn't work.

imageUploadUrl: (file, callback) => {
    const formData = new FormData();
    formData.append("file", file);
    axiosInstance({
      url: "/file-uploads",
      method: "POST",
      data: formData,
      headers: {
        "Content-Type": "multipart/form-data",
        Accept: "application/json",
      },
    }).then((res) => {
      callback(res.data.url);
    });
},


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source