2017-07-05 4 views
0

SendGridを使用しているときに次のエラーが発生します。私はエラーが出てもメールはまだ送られています。SendGridステータス202 node.js

ヌル{からstatusCode:202、本体: ''、ヘッダー:{サーバー: 'nginxの' 日付: '水、2017年7月5日18時50分52秒GMT' 'コンテンツタイプ': 'text/plain;接続: 'close'、 'x-message-id': 'EUkSULsjRku6bJTkTFsQ9w'、 'x-frame-options': 'DENY' 、 'アクセス制御許可元': 'https://sendgrid.api-docs.io'、 'アクセス制御許可メソッド': 'POST'、 'アクセス制御許可ヘッダー': '許可、コンテンツタイプ、オンx-sg-elas-acl '、 ' access-control-max-age ':' 600 '、 ' x-no-cors-reason ':' https://sendgrid.com/docs/Classroom/Basics/API/cors.html '}} _http_outgoing.js: 357 新しいエラーをスローする( '送信後にヘッダーを設定できない');次のコードを使用して

var helper = require('sendgrid').mail, 
    sg = require('sendgrid')('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'); 

    var from_email = new helper.Email('my.mail'); 
    var to_email = new helper.Email('my.mai'); 
    var subject = 'Subject'; 
    var content = new helper.Content('text/plain', 'test'); 
    var mail = new helper.Mail(from_email, subject, to_email, content); 

    var request = sg.emptyRequest({ 
     method: 'POST', 
     path: '/v3/mail/send', 
     body: mail.toJSON() 
    }); 

    sg.API(request, function(err, response) { 
     console.log(err, response); 
     if (!err) { 
      res.send({ 
       message: 'An email has been sent to the provided email with further instructions.' 
      }); 
     } else { 
      return res.status(400).send({ 
       message: 'Failure sending email' 
      }); 
     } 
    }); 

どのように私はこの問題を解決することができますか?

答えて

関連する問題