
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
4-5 Watcha Pedia 개발 강의에서 Google Book API 를 이용해서 검색을 하는데 검색 결과 에러가 나옵니다.
"dog"를 검색하면 dog 관련된 책이 검색되는 것이 아니라 서버에서 아래와 같이 에러를 보내줌.
(해당 URL을 크롬에 직접 입력해도 동일한 에러가 나옴)
{
}
작성한 코드 및 에러 메세지
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'book.dart';
class BookService extends ChangeNotifier {
List<Book> bookList = []; // 책 목록
void search(String q) async {
if (q.isNotEmpty) {
Response res = await Dio().get(
"https://www.googleapis.com/books/v1/volumes?q=$q&startIndex=0&maxResults=40",
);
List items = res.data["items"];
print(q);
print(items);
}
}
}
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
<Debug Console 에 있는 에러 메시지>
E/flutter ( 7461): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DioException [bad response]: This exception was thrown because the response has a status code of 429 and RequestOptions.validateStatus was configured to throw for this status code.
E/flutter ( 7461): The status code of 429 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
E/flutter ( 7461): Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
E/flutter ( 7461): In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.
E/flutter ( 7461):
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
