Angular core.js:6272错误:Uncaught(承诺中):HttpErrorResponse:{quot;headers";:{quot;normalizedNames";SendGrid和CloudFireStore

Angular core.js:6272错误:Uncaught(承诺中):HttpErrorResponse:{quot;headers";:{quot;normalizedNames";SendGrid和CloudFireStore,angular,firebase,ionic-framework,google-cloud-functions,sendgrid,Angular,Firebase,Ionic Framework,Google Cloud Functions,Sendgrid,我使用了带有Firebase云功能的SendGrid NodeJS库。它工作正常,我可以发送电子邮件。但在fire Under Cloud功能之后,Ionic/Angular客户端应用程序的控制台上显示以下错误。你知道为什么吗 core.js:6272 ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames": {}

我使用了带有Firebase云功能的SendGrid NodeJS库。它工作正常,我可以发送电子邮件。但在fire Under Cloud功能之后,Ionic/Angular客户端应用程序的控制台上显示以下错误。你知道为什么吗

     core.js:6272 ERROR Error: Uncaught (in promise): 
     HttpErrorResponse: {"headers":{"normalizedNames":
    {},"lazyUpdate":null},"status":200,"statusText":"OK","url":"https://my-
    app.cloudfunctions.net/sendEmail","ok":false,"name":"HttpErrorResponse","message"
    :"Http failure during parsing for https://my-
    app.cloudfunctions.net/sendEmail","error":{"error":{},"text":"success"}}
            at resolvePromise (zone-evergreen.js:793)
            at zone-evergreen.js:707
            at SafeSubscriber._error (Observable.js:91)
            at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
            at SafeSubscriber.error (Subscriber.js:135)
            at Subscriber._error (Subscriber.js:75)
            at Subscriber.error (Subscriber.js:55)
            at MapSubscriber._error (Subscriber.js:75)
            at MapSubscriber.error (Subscriber.js:55)
            at FilterSubscriber._error (Subscriber.js:75)
package.json

云函数

客户端应用程序的服务

从'@angular/core'导入{Injectable};
从'@angular/common/http'导入{HttpClient,HttpHeaders};
从'src/environments/environment'导入{environment};
从'src/app/models/sell my house.model'导入{SellMyHouseModel};
@注射的({
providedIn:'根'
})
导出类SendEmailService{
构造函数(私有httpClint:HttpClient){}
发送电子邮件(sellMyHouse:sellMyHouse模型):承诺{
返回this.httpClint.post(environment.cloudFunctionUrl+'sendmail',sellMyHouse,this.createHeader('application/json')).toPromise();
}
私有createHeader(contentType:string):任意{
返回{headers:newhttpheaders({'Content-Type':contentType})};
}
}

我已经这样做了,不再有上述问题。例如,
响应类型:'text'

 private createHeader(contentType: string): any {
    return { headers: new HttpHeaders({ 'Content-Type': contentType }), responseType: 'text' };
  }

我已经这样做了,不再有上述问题。例如,
responseType:'text'

 private createHeader(contentType: string): any {
    return { headers: new HttpHeaders({ 'Content-Type': contentType }), responseType: 'text' };
  }

我不知道错误是在哪里触发的,但错误消息告诉您,在承诺期间触发了一个错误,但它没有被捕获。请看一下。另外,在您客户的服务中有一个输入错误,您使用了
httpClint
而不是
httpClient
。但这不会导致代码出现问题。@Ajordat是的,是打字错误。我会解决的。谢谢。你认为
try/catch
会在这里提供更多信息吗?try/catch应该会提供更多信息,是的。你能解决你的问题吗?@asbovelw我已经给出了答案。请查看。我不知道错误是在哪里触发的,但错误消息告诉你错误是在触发的在一次承诺中被删除了,但没有被捕获。请看一下。在您客户的服务中也有一个输入错误,您使用了
httpClint
而不是
httpClient
。但这不会导致代码出现问题。@Ajordat是的,这是输入错误。我会解决的。谢谢!您认为
try/catch
会在这里提供更多信息吗try/catch应该会提供更多信息,是的。你能解决你的问题吗?@asbovelw我已经给出了答案。请看。你保存了我的日期。我的api返回的是纯字符串,但请求的默认响应类型是json。所以我们需要在其中任何一个位置进行修复。你保存了我的日期。我的api返回的是纯字符串,但请求的默认响应类型是json、 所以我们需要在这两个地方中的任何一个进行修复。
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { SellMyHouseModel } from 'src/app/models/sell-my-house.model';

@Injectable({
  providedIn: 'root'
})
export class SendEmailService {

  constructor(private httpClint: HttpClient) { }

  sendEmail(sellMyHouse: SellMyHouseModel): Promise<any> {
    return this.httpClint.post(environment.cloudFunctionUrl + 'sendEmail', sellMyHouse, this.createHeader('application/json')).toPromise();
  }

  private createHeader(contentType: string): any {
    return { headers: new HttpHeaders({ 'Content-Type': contentType }) };
  }

}
 private createHeader(contentType: string): any {
    return { headers: new HttpHeaders({ 'Content-Type': contentType }), responseType: 'text' };
  }