Solved

Call an api endpoint from an angular application

  • 23 February 2023
  • 4 replies
  • 126 views

Badge +1

Hi.

In documentation exists an example to call the add_account_properties’ endpoint from a javascript project.


But when I call this from angular API, I have a cors errors. Has anyone else experienced this? What am I doing wrong?


 

icon

Best answer by jonathan 25 February 2023, 01:14

View original

4 replies

Userlevel 4
Badge +3

Hey there! Have you followed all of the steps on the account health analysis guide? https://help.heap.io/charts/chart-features/account-health-analysis/

I’ve found the API can shoot errors when it’s looking for something that isn’t there. 

Userlevel 5
Badge +3

Hey @joaomendes — Thanks for this post. I had no idea our docs platform took it upon themselves to create code examples that are flat out not supported. Crazy! Under JS, the axios example should work, since it’s going to be executed on a node server, probably, but the fetch, jQuery, and XMLHttpRequest examples will not because they happen on the client.

As of right now, we don’t support hitting our POST endpoints from the browser. There’s a planned task to unblock this, timing TBD. But that’s why you’re seeing the CORS error.

I’ll follow up with engineering to get a timeline on that change, and with the docs team so they can disable examples that won’t work. 

Userlevel 3
Badge +3

Hi @joaomendes , thank you for your post. We added a clarifying statement to our Add Account Properties docs while we work on eliminating the erroneous examples from our docs. 

Badge +1

Thanks @julia and @jonathan.

 

I was really confused. :)

 

When it is possible to call POST endpoints from the browser, let me know.

Reply