How do I use post to upload files with other parameters in an ionic project?

there is a problem encountered in the ionic project. You need to upload a file through the API post, and two parameters can be adjusted on postman, but you don"t know how to write it in the ionic project. If anyone encounters a similar problem, try to crack the method.
the picture shows the effect of successful upload on postman:

Apr.27,2021

  constructor(
    public http: HttpClient) {} 
  
  public test():Observable<any> {
   let form = new FormData();
    form.append('id',id);
    form.append('type',type);
    form.append('file',file);

    return this.http.post(URL,form)
  }
    

in fact, you can click the code button in postman. If there is a code example, you can almost know it by looking at the code example of javascript.

clipboard.png


Content-TypeAccessToken

clipboard.png

Menu