Skip to content

Type 'HttpEvent<{}>' is not assignable to type 'HttpEvent<Event>'. #28

Closed
@aulona2014

Description

@aulona2014

I tried this but for me doesn't function

  postUrl = '(Api.getUrl(Api.URLS..........)';
  myFormData: FormData ;//populated by ngfFormData directive
  httpEvent: HttpEvent<Event>;

  uploadFiles(files:File[]) : Subscription {
    const config = new HttpRequest('POST', this.postUrl, this.myFormData), {
      reportProgress: true
    }) // exception [ts] Cannot redeclare block-scoped variable '(Missing)'.
    
    return this.HttpClient.request( config )
    .subscribe(event=>{
      this.httpEvent = event //exception Type 'HttpEvent<{}>' is not assignable to type 'HttpEvent<Event>'.
      
      if (event instanceof HttpResponse) {
        alert('upload complete, old school alert used')
      }
    },
    error=>{
      alert('!failure beyond compare cause:' + error.toString())
    })
  }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions