score:2
Accepted answer
Problem is that http://dummy.restapiexample.com/api/v1/employees returns array while https://randomuser.me/api/ returns object. Try changing to
componentDidMount() {
Axios.get("https://randomuser.me/api/").then(res => {
const results = res.data.results;
this.setState({ results });
console.log(results);
});
}
score:0
You have to use res.data.results. It comes in results object.
score:0
Please check your JSON data last line you missed the "}]" typo error in http://dummy.restapiexample.com/api/v1/employees
componentDidMount() {
Axios.get("http://dummy.restapiexample.com/api/v1/employees").then(res => {
const results = res.data;
this.setState({ results: results });
});
}
Source: stackoverflow.com
Related Query
- reactjs axios cant get api data
- For some reason, cant get the data from an api to render on the screen using axios in Reactjs
- How to Assign react redux state api get data using axios
- Delete data from API with Axios and ReactJS
- use axios with react to get data from api
- The data I want to get from API using Axios returns undefined
- Post Data With Redux and Fetch API with Axios Get Error Result so Looping Response Pending
- When i try to call the api data from axios i get 404 error
- Axios get data from API - React.js
- how to pass string params in Get call of API using axios in Reactjs
- Not able to resolve issue with api of OpenWeatherApi for fetching weather data of a city using City id using axios in Reactjs
- React and Express: Using Axios to GET data from 3rd party API
- Fetching data from Api in Reactjs using Axios
- Get API Json data in object and array format using redux and reactjs
- Reactjs onClick not rerendering data when sent to child component to get info from api
- How to get data as JSON from this API and display in in my Reactjs app
- how to get data into an array after post using axios in reactjs
- How to get Data from api using axios in redux-toolkit
- Get Data from api in redux-saga reactJS
- API is working but I can't get axios to write out the data being returned from the API
- ReactJs update state from axios api data
- react get data from rest api with axios and and useEffect redering empty array plus array with data
- how to get spesific data from api with axios and react js?
- How to get data from api using axios
- How to concatenate URL and string, and get data from API at click a button using axios in REACT JS
- Openlayers Geojson axios API Get data
- ReactJS : Axios get request with header and data leads to bad request 400
- How i get response data from api url usinf fetch in reactjs
- Get form data in ReactJS
- ReactJS API Data Fetching CORS error
More Query from same tag
- how do i change react mui mobilestpper dots color?
- Meteor React Subscription
- Load image from server that requires sending headers
- TypeError: "name" is read-only
- How to change the background color of a parent component from inside a child component in react, gatsby
- conditional passing functions as props to a component
- redux-form isDirty not reset after successful submit
- How to make a simple loop slider in the React?
- What actually happens when React component returns?
- Why does the twitter widget not re-render reactjs
- carousel keeps anchoring to the top of page on image change
- How can I get and store Data from Textfield in Form Container?
- How can I get an instance of the Cesium viewer from document?
- How to create a conditional rendering of Gatsby's Link component and <a> tag for links?
- How to set the height of a Material-UI's Grid item equals to its width responsively?
- Cannot print string using ReactJS
- Typing props spread when using InferProps<> from prop-types
- Crashed on heroku
- useForm in react is not working properly for two manual update
- Auto scroll ONLY child component, NOT parent
- React and real DOM cooperation in LeafletJS
- How to merge Constants inside a URL So it won't break the url
- React-Table returning remaining items after filtering?
- Prevent useEffect retriggering when updating state from specific function
- Access props inside quotes in React JSX
- Href to another page React Gatsby
- Material-ui-next typescript error
- Request failed when using Axios in ReactJs and Laravel
- How to use spread operator to update array inside an object?
- Stripe Connect w/ React