1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Fake API is giving a CORS error with Angular

Discussão em 'Angular' iniciado por rahemanali, Junho 9, 2025.

  1. rahemanali

    rahemanali Guest

    I am getting a CORS error when I make a backend call, and I can't solve it when I use a Fake API. How can I solve this CORS problem?

    Access to XMLHttpRequest at 'https://<redacted>/api/BigBasket/GetAllProducts' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


    This is the function that makes the web request:

    getCategory(){
    return this.http.get(Constant.API_END_POINT + Constant.METHODS.GET_ALL_CATEGORY)
    }


    This is the function where I am calling getCategory from the API:

    getAllCetegory(){
    this.productService.getCategory().subscribe((res:any) => {
    try {
    this.categoryList = res.data
    console.log("hrre the", this.categoryList);
    } catch (error) {
    console.log("error hai ", error)
    }
    })
    }


    These are my constants:

    API_END_POINT: 'https://<redacted>/api/BigBasket/',
    API_END_POINT_USER: 'http://<redacted>/api/User/',

    Continue reading...

Compartilhe esta Página