发送邮件请求到服务器时出错 .

我的服务器将接受类型 JSON 数据 . 在这里,我编写了 angular app 来发送数据 .

这是我的组件代码:

import { Component, OnInit, ViewChild } from '@angular/core';
import { FormsModule, FormGroup, FormControl } from '@angular/forms';
import {HttpModule, Http, URLSearchParams, Headers, RequestOptions} from '@angular/http';
import  'rxjs/Rx';
class Signup {
constructor(public firstName: string = '',
          public lastName: string = '',
          public email: string = '',
          public password: string = '',
          public cpassword: string = '') {
 }
}

@Component({
 selector: 'app-createuser',
 templateUrl: './createuser.component.html',
 styleUrls: ['./createuser.component.css']
 })
 export class CreateuserComponent implements OnInit {
 data;
 data1='test';
  model: Signup = new Signup();
  url = "http://ewalltechnologies.in/m2/ecommerce/rest/V1/customers";
  @ViewChild('f') form: any;
  constructor(private http: Http) { }

   ngOnInit() {
   }

   onSubmit() {
   if (this.form.valid) {
     console.log("Form Submitted!");
  let cust:any={'email':this.model.email,'firstname':this.model.firstName,'lastname':this.model.lastName};
 let test={'customer':cust,'password':this.model.password};
  this.data=test;
 let search = new URLSearchParams();
 search.set('username', 'nagaraju.k@ewallsolutions.com');
 search.set('password', 'ewall@123');
 this.http.post("http://ewalltechnologies.in/m2/ecommerce/rest/V1/integration/customer/token",{username:'nagaraju.k@ewallsolutions.com',password:'ewall@123'}).subscribe(res => console.log(res.json()))
 this.test().subscribe(res => console.log(res),
 err => console.log(err),
 () => console.log("Done") );
}
 }
 test()
 {
   let body = this.data;
  let headers: Headers = new Headers();
  headers.append('Content-Type', 'application/json');
  let opts: RequestOptions = new RequestOptions();
  opts.headers = headers;
   return this.http.post(this.url, body,opts).map(res => res.json());
}
}

这是我在传递请求后得到的错误 .

阻止跨源请求:同源策略不允许在http://ewalltechnologies.in/m2/ecommerce/rest/V1/integration/customer/token上读取远程资源 . (原因:CORS预检 Channels 没有成功) . 跨源请求已阻止:同源策略不允许在http://ewalltechnologies.in/m2/ecommerce/rest/V1/customers上读取远程资源 . (原因:CORS预检 Channels 没有成功) .