0
votes

I have a problem when i send two objects in Angular post request (in body), i receive in my controller null for those objects, here is my angular request, first object is FormData (with one or multiples images) and second is a type that i created My Controller with null

here is the post from angular :

    const email = localStorage.getItem('email');
const obj = {
  userEmail: email,
  vehicle: vehicle
}

this.uploadedImage.forEach((file: File, i) => {
  imageFormData.append('imageFormData', this.uploadedImage[i]);
})

this.httpClient.post('http://localhost:8080/api/v1/add-image', { imageFormData, obj }, { observe: 'response' })
  .subscribe((response) => {
    if (response.status === 200) {
      this.postResponse = response;
      this.successResponse = this.postResponse.body.message;
    } else {
      this.successResponse = 'Image not uploaded due to some error!';
    }
  }
  );

}

Can someone help me please, i don't know what is wrong in my work.

Thank you all. Have a nice day !

Edit : In the picture, Object UserAndVehicle contains all fields as null