score:0
Accepted answer
you are not calling appropriate method of axios. use get() method
try this:
searchmovies = async val => {
this.setstate({ issearching: true })
const res = await axios.get(
`https://api.themoviedb.org/3/search/movie?api_key=${apikey}&language=en-us&query=${val}page=1&include_adult=true`;
)
const movies = await res.data.results;
this.setstate({ movies: movies, issearching: false })
}
score:1
i think you should use get() method in your searchmovies function.
const response = await axios.get('/user?id=12345');
console.log(response);
Source: stackoverflow.com
Related Query
- Getting an empty array in React while fetching the data from the api
- Why am i getting an empty array in my image? Fetching data from strapi
- How to fix the state update in react while getting data from firestore database
- Too many re-renders React error while fetching data from API
- Getting data from mongoose on server but an empty array in React
- fetching data from the Dog API using axios and saving data into a new array
- Fetching data first time from API endpoint it return empty array, after that return array with real information
- getting error while destructuring the data from react redux. why it is giving error and how to solve this?
- Why am i getting and empty array when fetching an api with react hooks?
- How to add multiple Objects to an empty array react after getting response from Api react
- Invalid hook call React while fetching data from an API
- Formatting the received data from an api into an array React Axios
- Fetching the data from second api based on the response from the first api React js
- I made an API call fetching data from it on a React component and passed it on to a state. I want to use the same data on another component too
- TypeError: data.forEach is not a function in react while fetching data from API
- React hooks doing an infinite fetching when getting data from child but has no problem if the parent is a class component
- Getting data from a JSON array and setting states based on the data using loop in React
- react get data from rest api with axios and and useEffect redering empty array plus array with data
- useSWR not getting data from api while fetch() to the same adress returns data
- Gettin 'null' while fetching data from api with React Context
- Fetching array of objects from api and storing to usestate but getting empty array
- Getting data from an API array in React
- State variable is not updated in onClickHandler while using Hooks for getting data from an API by a user input in react
- Set the data in React Context from asynchronous API call
- React query mutation: getting the response from the server with onError callback when the API call fails
- React - this.state is null inside render when getting data from API
- REACT - Set initial data in Formik Form after fetching from API
- Fetching data from store if exists or call API otherwise in React
- React is not updating the UI after receiveing data from the API call (using hooks)
- React not fetching data from the updated env file
More Query from same tag
- How can I interpolate JSX with an expression in a string?
- ReactJS handleChange on every HTML input
- Create a table from JSON completely dynamically
- Two Components Connected to Each-other
- Updating a child object in React with UseState (and connecting it back to parent object)
- Rest API React and AXIOS in functional component
- How to pass information between similar components in react js
- Custom onChange event Formik
- sessionStorage doesn't update the page
- Generic props : why are these types incompatible?
- how to refactor .bind(this) into ES6 syntax
- How to refresh a nested Component view that shows the result for a search being done in React
- How to populate React array from JSON Nodejs back end
- Async data flow in React App with Redux + ReactRouter?
- sending input value to backend using react & axios
- Conditional Rendering,use-timeout Invalid hook call React
- Using event listener should we use useCapture as false to support old browser or it will be used as default for every browser
- Resizing canvas to fit within container
- Automatically play audio on website after delay
- Gatsby Module Federation CORS error and eager consumption issue
- handling event and interchangeable state in hooks
- Getting 400 Error while Authenticating user credentials using fetch API
- The click is apply on <tr> and in tr there is also button onclick event
- tailwind how to make nav tabs always show scroll bar?
- How to deal with code that depends on document.title in Next.js with SSG?
- how to add object into array with hook state in react js
- How to update the state of a field programmatically using redux-form
- Unable to change value of component programmatically using useState
- ReduxToolkit useSelector Hook: React functional component doesnt rerender after selected redux-state is updated through useDispatch
- React-Virtualized Table only showing one column