반응형 restapi1 GraphQL로 restAPI 사용하기 기존 RestAPI를 GraphQL로 감싸주었다. db.js에서는 url을 fetch한 리턴값을 getMovies에 할당했다. //db.js import fetch from "node-fetch"; const API_URL = "https://yts.am/api/v2/list_movies.json?"; export const getMovies = (limit, rating) => { let REQUEST_URL = API_URL; if (limit > 0) { REQUEST_URL += `limit=${limit}`; } if (rating > 0) { REQUEST_URL += `&minimum_rating=${rating}`; } return fetch(`${REQUEST_URL}`) .then((r.. 2022. 1. 23. 이전 1 다음 반응형