Unable to Call Get Request Using HttpClient Object in Angular 8

210 views Asked by At

I am trying to write a method which going to check whether the URL is correct or not. For that, I have written a method in Angular like below.

checkUrlValidation(url){
  return this.http.get(url,{withCredentials:true})
  .pipe(catchError((error)=>{
    return new Promise((resolve,reject)=>{
      console.log("HAHAHAHAHAHHAH")
      if(error.status == 200){
        resolve(true);
      }else{
        reject(false);
      }
    });
  }));
}

And When i call this method i will get following error:

Access to XMLHttpRequest at 'https://coreui.io/docs/components/forms/' from origin 'http://localhost:4200' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Any help would be highly appreciated.

0

There are 0 answers