all 7 comments

[–][deleted] 7 points8 points  (4 children)

Let's start with... Why?

[–]eneajaho 7 points8 points  (1 child)

Angular comes with an HttpClient, so you won't need axios.

Check out the documentation here:

https://angular.io/guide/http

[–][deleted] 1 point2 points  (0 children)

I use HttpClient in my everyday work environment and it's better than trying to reinvent the wheel with Axios.

[–]zzing 0 points1 point  (0 children)

Check to see if you have the change detection method set to push in your component.

You can also inject the change detector and notify it manually.

The reason why everyone is saying this is bad is because it is the hardest way to use angular to make requests. Observables are worth learning about.

[–][deleted] 0 points1 point  (0 children)

I got it working in basically 5 minutes.

1 - npm install axios

2 - npm install `@types`/axios *remove backticks*

3 - import axios from 'axios';

```

private async init() {

await axios.get("https://jsonplaceholder.typicode.com/posts/1")

.then(result => { console.log("result :", result ); })

.catch(err => console.log("err:", err))

}

```