I get the following error when I try to implement headers
The type" Headers "has no properties in common with the type" RequestOptionsArgs "
I was reading that apparently now we should use HttpHeaders
but I can not implement it without avoiding the error
import { Component, OnInit } from '@angular/core';
import { Http, Headers, Response, URLSearchParams } from '@angular/http';
import 'rxjs/add/operator/toPromise';
@Component({
selector: 'app-contacto',
templateUrl: './contacto.component.html',
styleUrls: ['./contacto.component.scss']
})
export class ContactoComponent implements OnInit {
constructor(private http: Http ) { }
ngOnInit() {
}
sendMessage(){
let url = `https://your-cloud-function-url/function`
let params: URLSearchParams = new URLSearchParams();
let headers = new Headers({'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' });
params.set('to', 'user@example.com');
params.set('from', 'you@yoursupercoolapp.com');
params.set('subject', 'test-email');
params.set('content', 'Hello World');
return this.http.post(url, params, headers)
.toPromise()
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
}