Hi coders!
I’m currently working on getting data from JSON placeholders as per the lesson with Mosh.
In this video, we used async await to retrieve the data. I understand that async works as a parallel programming where it runs units of the code behind.
So now when applying async await to this particular code:
async componentDidMount() {
//pending > resolved or failure
const { data: posts } = await axios.get(
"https://jsonplaceholder.typicode.com/posts"
);
//set it into the state so then we can use it.
this.setState({ posts });
}
What I’m trying to understand here is more on the benefits. Is it right for me to assume that… by applying async await, the Vidly app as a whole when it loads it does not depend to wait for the JSON placeholder data to load first right?