1

I have tried to send file using HttpClient:

 public async uploadProfile(data: UploadProfile): Promise<any> {
    return await this.http.post(this.uploadProfileUrl, data).toPromise();
 }

Before sending file I prepare it to binary array:

interface UploadProfile {
    file: any;
}


file = [123, 10, 32, 32, 34, 100, 105, 115, 97, 98, 108, 101, 83, 105, 122, 101, 76, 105, 109]

But I get error:

TypeError: Cannot read property 'toLowerCase' of undefined
    at HttpXsrfInterceptor.intercept (http.js:2177)
1
  • do you have a httpInterceptor? and whats the value of this.uploadProfileUrl Commented Nov 30, 2019 at 15:27

1 Answer 1

1

This is likely due to an undefined url during your request. Try to do the following as a test:

Change:

 public async uploadProfile(data: UploadProfile): Promise<any> {
    return await this.http.post(this.uploadProfileUrl, data).toPromise();
 }

To:

 public async uploadProfile(data: UploadProfile): Promise<any> {
    return await this.http.post('http://yourUrl/resource', data).toPromise();
 }

If this works and you don't see the error anymore, try to find why uploadProfileUrl is undefined when you make the call.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.