your initial state for posts is an object, but after fetching you set it as an array. i suggest to make the initial state as an empty array or null
you have a state property called "errors", but when you catch your rejected promise from axios, you are setting the error to a property called "error". suggest change the state property name from "errors" to "error"
suggest using the error state property in some way
you have a state property called "loading" that is a string which is never changed. suggest to hardcode the "Loading..." string in the <p> tag and instead of using "isLoading" as the boolean, "isLoading" can be removed and you can use "loading" as the boolean instead now.
you are doing a named export: export class Fetchdata extends Component { as well as a default export export default Fetchdata; for the Fetchdata component. suggest to remove the named export as react components are usually exported using default.
you solved the CORS issue from the open liberty side, which is valid. but there is another way if you are using create-react-app by adding a proxy property in the package.json. (optional)
your initial state for posts is an object, but after fetching you set it as an array. i suggest to make the initial state as an empty array or null
you have a state property called "errors", but when you catch your rejected promise from axios, you are setting the error to a property called "error". suggest change the state property name from "errors" to "error"
suggest using the error state property in some way
you have a state property called "loading" that is a string which is never changed. suggest to hardcode the "Loading..." string in the
<p>
tag and instead of using "isLoading" as the boolean, "isLoading" can be removed and you can use "loading" as the boolean instead now.you are doing a named export:
export class Fetchdata extends Component {
as well as a default exportexport default Fetchdata;
for the Fetchdata component. suggest to remove the named export as react components are usually exported using default.you solved the CORS issue from the open liberty side, which is valid. but there is another way if you are using create-react-app by adding a proxy property in the package.json. (optional)