score:1
Accepted answer
your code looks correct, but you must make sure that the prediction
you get in the response to your request is a number.
class app extends component {
// ...
fetchdata = () => {
fetch("http://localhost:8000")
.then(resp => resp.json())
.then(data => {
this.setstate({ prediction: number(data.prediction) });
})
.catch(error => {
console.log(error, "catch the hoop");
});
};
// ...
}
Source: stackoverflow.com
Related Query
- Colors of CSS elements do not change correctly
- React css transition does not work correctly
- React Router Warning: <Route> elements should not change from controlled to uncontrolled (or vice versa)
- Simulate change does not work for formik's select elements
- Elements doesn't survive state change for css transitions in React
- Change in CSS left property not animating
- CSS not rendered correctly
- Change in state not affecting other elements
- How to change class on hover in React without useState or so that not all elements are triggered
- Not able to change svg elements color by looping
- Update: Redux reducer is not beeing called to change CSS classes
- style.setProperty changes css variables in html element but style of elements using those variables doesn't change
- React - Redux component not displaying array.length correctly despite component being rerendered on state change without mutating the state
- Material Ui button colors not changed after theme change
- NextJS - Not Able To Use Custom Colors In Tailwind CSS In
- Create triangle that do not change angle in css
- inline CSS style is not getting rendered [Previously: Component is not rendering its elements - react]
- Array state not pushing elements correctly from input field
- TailwindCSS and React Not Correctly Importing JSX Elements
- div will not change size with CSS properties
- CSS position absolute elements not aligning properly with their sibling elements
- React element not expanding correctly in CSS Flex container
- CSS Changes not reflected on associated state change in React with React Hooks
- React/Webpack Css imports from node_modules are not loading correctly
- CSS style is not correctly being applied when conditional render in React
- Why CSS is not applying correctly to button in react material web components?
- components css styling does not change when re-rendering it with different props (rerender())
- React Button with mui not changing colors correctly
- Mapping through Data does not Return CSS Correctly
- React component not re-rendering and showing CSS change upon value changing
More Query from same tag
- How to position this button to the right in this Navbar
- Add loader on button click in react/redux application
- Relay Modern, prop not supplied
- How to get promises to work in IE10 with react
- flexbox: No space between two vertical icons
- Update array but retain existing array in map
- Component with specific child aggregations in React / Typescript
- How can I fetch data out of a component, using useParams in React.js?
- Loading a script in react
- Redux: re-rendering children on store state update
- Printing HMTL elements
- Saga not running when action creator being called inside componentDidMount
- VM1374:32 Uncaught TypeError: Converting circular structure to JSON(…)
- How to pass variable to GraphQL filter query?
- How to access state outside of a component
- react I want to change the style in the props I pass
- How to properly return value from a data inside the function
- Reactjs:How to hide node modules and webconfig in the devtools on production app?
- How to call custom proptype function with ES6 React class
- react-select select multiple items in the drop-down list
- React setState not working after deleting data from state copy
- Cannot read property 'handleReset' of undefined
- validateDOMNesting(...): <button> cannot appear as a descendant of <button>
- In React, how can I use children?
- use setState Hook to update previous value based on a set of conditions in React JS
- Three columns responsive
- Cannot read images from Tensorflow.js Tensorcamera on React Native
- Guidelines to build a secure JWT authentication process?
- i have problem with converting function in class component to functional
- Adding style attributes to a css class dynamically in react app