title: core.js:6272 ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames" SendGrid and Cloud Firestore
body: <p>I have used the SendGrid NodeJS library with Firebase Cloud function. It works fine and I can send an Email. But it shows below error on the Ionic/Angular client app's console after the fire below Cloud function. Do you know why?</p>
  <pre><code>     core.js:6272 ERROR Error: Uncaught (in promise): 
       HttpErrorResponse: {&quot;headers&quot;:{&quot;normalizedNames&quot;:
      {},&quot;lazyUpdate&quot;:null},&quot;status&quot;:200,&quot;statusText&quot;:&quot;OK&quot;,&quot;url&quot;:&quot;https://my-
      app.cloudfunctions.net/sendEmail&quot;,&quot;ok&quot;:false,&quot;name&quot;:&quot;HttpErrorResponse&quot;,&quot;message&quot;
      :&quot;Http failure during parsing for https://my-
      app.cloudfunctions.net/sendEmail&quot;,&quot;error&quot;:{&quot;error&quot;:{},&quot;text&quot;:&quot;success&quot;}}
              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)
  </code></pre>
  <p><em>package.json</em></p>
  <pre><code>{
    &quot;name&quot;: &quot;functions&quot;,
    &quot;scripts&quot;: {
      &quot;lint&quot;: &quot;tslint --project tsconfig.json&quot;,
      &quot;build&quot;: &quot;tsc&quot;,
      &quot;serve&quot;: &quot;npm run build &amp;&amp; firebase emulators:start --only functions&quot;,
      &quot;shell&quot;: &quot;npm run build &amp;&amp; firebase functions:shell&quot;,
      &quot;start&quot;: &quot;npm run shell&quot;,
      &quot;deploy&quot;: &quot;firebase deploy --only functions&quot;,
      &quot;logs&quot;: &quot;firebase functions:log&quot;
    },
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;10&quot;
    },
    &quot;main&quot;: &quot;lib/index.js&quot;,
    &quot;dependencies&quot;: {
      &quot;@sendgrid/mail&quot;: &quot;^7.2.1&quot;,
      &quot;@types/cors&quot;: &quot;^2.8.6&quot;,
      &quot;axios&quot;: &quot;^0.19.2&quot;,
      &quot;cors&quot;: &quot;^2.8.5&quot;,
      &quot;firebase-admin&quot;: &quot;^8.10.0&quot;,
      &quot;firebase-functions&quot;: &quot;^3.6.1&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;tslint&quot;: &quot;^5.12.0&quot;,
      &quot;typescript&quot;: &quot;^3.8.0&quot;,
      &quot;firebase-functions-test&quot;: &quot;^0.2.0&quot;
    },
    &quot;private&quot;: true
  }
  </code></pre>
  <p><em>Cloud Function</em></p>
  <pre><code>import * as functions from 'firebase-functions';
  import * as sgMail from '@sendgrid/mail';
  import * as cors from 'cors';
  
  const corsHandler = cors({ origin: true });
  
  export const sendEmail = functions.https.onRequest((request, response) =&gt; {
  
      return corsHandler(request, response, async () =&gt; {
  
          const apiKey = functions.config().sendgrid.key;
          const emailTemplateId = functions.config().sendgrid.template;
  
          sgMail.setApiKey(apiKey);
  
          const email = {
              templateId: emailTemplateId,
              from: 'me@y.com',
              to: 'me@y.com',
              dynamic_template_data: {
                  firstName: request.body.firstName,
                  lastName: request.body.lastName,
               },
          };
  
          try {
              await sgMail.send(email);
              response.send('success');
  
          } catch (err) {
              console.log(&quot;Send Email request failure&quot;, err);
              response.send('failure');
          }
      });
  });
  </code></pre>
  <p><em>Client app's service</em></p>
  <pre><code>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&lt;any&gt; {
      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 }) };
    }
  
  }
  </code></pre>