C
C
c00ldev2019-12-20 21:53:24
React
c00ldev, 2019-12-20 21:53:24

Why doesn't simple search work?

My attempts:
https://codesandbox.io/s/charming-khorana-hbnm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2019-12-20
@c00ldev

error in getMovies(text) declaration

getMovies = text => async () => { }
// другими словами ты возвращаешь async функцию
function getMovies(text) {
  return async function() { }
}

// а надо так
getMovies = async text =>  {
  try {
    const URL = `https://api.tvmaze.com/search/shows?q=${text}`;
.....

and change a bit
renderPosts() {
    if (this.state.error) {
      return this.renderError();
    }

    return (
      <ul>
        {this.state.posts.map(post => (
          <li key={post.show.id}>{post.show.name}</li>
        ))}
      </ul>
    );
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question