标题属性问题

时间:2018-04-18 20:19:13

标签: angular

我有一个在用户提交表单时发送电子邮件的功能

sendEmail() {

   let url = `the url placeholder`
   let params: URLSearchParams = new URLSearchParams();
   let headers = new Headers({'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' });
   let message = this.firstName + " " + this.lastName + " has submitted the following form: " + this.cons.name;

   params.set('to', 'email placeholder');
   params.set('from', 'email placeholder');
   params.set('subject', 'A user has submitted a form');
   params.set('content', message);

   return this.http.post(url, params, headers)
                   .toPromise()
                   .then( res => {
                     console.log(res)
                   })
                   .catch(err => {
                     console.log(err)
                   })

 }

我收到以下错误

ERROR in src/app/ownership-cost/ownership-form.component.ts(281,39): error TS2559: Type 'Headers' has no properties in common with type 'RequestOptionsArgs'.

我最近将我的角度应用程序从4.1.3升级到5.2.0,所以我不确定这是否会导致问题。

我该怎么做才能解决这个问题?

0 个答案:

没有答案