'How to send data as multipart in angular

I'm trying to send data to the backend in (multipart) form-data format where one is data in that I have to pass JSON and the other is file where I have to pass the file



Solution 1:[1]

  var fd = new FormData();
  fd.append('data', JSON.stringify(getVendorData));
  fd.append('file', JSON.stringify(this.image));

   return this.http
    .post(`${this.testingServer}`, query, {
      responseType: 'json'
    })
    .pipe(
      retry(3)
    );

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Asmita Patil