JS
React JS
React Axios Get Request Example
Now, let's see article of react axios get request with params example. I am going to show you about axios get request in react js. you will learn react http get request example. We will look at example of axios http request react. Follow bellow tutorial step of react axios http request example.
- TAGS
- React JS
- 4.5/5.0
- Last updated 08 September, 2022
- By Admin
If you want to learn how to send http get request with react then i will help you step by step instruction for sending http request using axios react. i will give you very simple example to send http get request using axios and react.
Axios is a npm package and the provide to make http request from your application. in this example we will use "jsonplaceholder" api to get data using axios package.
So, let's see bellow example code and preview:
Example Code:
import React from 'react'; import axios from 'axios'; export default class PostList extends React.Component { state = { posts: [] } componentDidMount() { axios.get(`https://jsonplaceholder.typicode.com/posts`) .then(res => { const posts = res.data; this.setState({ posts }); }) } render() { return ( ) } }React Axios Get Request Example - codewale.com
{this.state.posts.map((post) => ( ID Title Body ))} {post.id} {post.title} {post.body}
I hope it can help you...