title: I need to post url with rest API call. it was working in angular 1.6 but not able to post it with Angular 7
body: <p>I need to post url with angular 7 to the server but getting some error as "blocked by CORS policy" while it was working in angular 1.6</p>
  
  <p>Getting issue as :Access to XMLHttpRequest has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.</p>
  
  <pre><code>return this.http.post&lt;Driver&gt;(url, this.emailAttributeObject, {
                      headers : new HttpHeaders({
                          'Content-type' : 'application/json'
                      })
                  })
                      .pipe(
                          catchError(this.handleError('driverDetails', driverDetails))
                      );
  
  component file:
  this.myDataService.sendEmail(this.driverDetails, this.initialValue)
              .subscribe((response : Driver) =&gt; {
                      //this.driverDetails = response;
                  }, error =&gt;
                      this.toastr.error(error.message,"Problem to send Email")
              )
  
  service file:
  return this.http.post&lt;Driver&gt;(url, this.emailAttributeObject, {
                      headers : new HttpHeaders({
                          'Content-type' : 'application/json'
                      })
                  })
                      .pipe(
                          catchError(this.handleError('driverDetails', driverDetails))
                      );
  </code></pre>