· 6 years ago · Mar 12, 2020, 12:44 PM
1PHP API:
2header('Access-Control-Allow-Origin: *');
3header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
4header('Access-Control-Allow-Headers: token, Content-Type');
5header('Access-Control-Max-Age: 1728000');
6header('Content-Type: text/plain');
7
8ANGULAR:
9this.httpClient.post(URL,
10 {
11 key: value,
12 },
13 {
14 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
15 responseType: 'text'
16 })
17 .subscribe(data => {
18
19 }, error => {
20 console.log(error);
21 });