Hi,
I have an angular application that will upload files and within the application I have a variable called property.name and I would like to send this variable to my API server which is node.js
my upload typescript in angular:
onImageUpload1() {
const imageForm = new FormData();
imageForm.append('image', this.imageObj);
this.imageUploadService.imageUpload(imageForm).subscribe((res:any) => {
this.imageUrl = res['image'];
});
my upload service:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class UploadService {
constructor(private http: HttpClient) { }
imageUpload(imageForm: FormData) {
console.log('image uploading');
return this.http.post('http://localhost:3000/api/v1/upload/', imageForm);
}
}
my variable is in a different typescript file called add property and there I have the variable property.Name.
I know that one way is to get the variable from add property ts file to the upload ts file and add that to the form data that will be sent to the api server but not sure how?