이번 글에서는 http api를 이용하여 데이터를 주고받을 때 꼭 알아야 하는 url의 구조에 대해서 알아보도록 하겠습니다.
정말 간단하게 얘기해서 특정 사이트에 접속하기 위한 문자열 주소를 말합니다.
주소창 주소 예시
https://opentdb.com:443/api.php?amount=10&category=11&difficulty=hard&type=multiple
개념적 구조
scheme://host:port/path?query#fragment
위의 정보를 바탕으로 다음 URL을 한번 분석해 보겠습니다.
https://opentdb.com:443/api.php?amount=10&category=11&difficulty=hard&type=multiple
import 'package:http/http.dart' as http;
var url = Uri.https('opentdb.com', 'api.php?',
{'amount':10, 'category':11, 'difficulty: 'hard', type: 'multiple'});