자바스크립트

es6 문법 저장용(json api 가져올때)

안양사람 2020. 6. 30. 15:21
728x90
SMALL

 

    const {
      data: {
        data: { movies },
      },
    } = await axios.get("https://yts.mx/api/v2/list_movies.json");
    console.log(movies);
    // const movies = await axios.get("https://yts.mx/api/v2/list_movies.json");
    // console.log(movies.data.data.movies);

이런식으로 movies.data.data.movies라고 해야되는것을 조금 더 예쁘게? 가져올 수 있다

    this.setState({ movies });
    

 

728x90
LIST