AF.request(api.getURL,
method: api.method,
parameters: api.parameter,
encoding: api.encoding,
headers: api.header).responseDecodable(of: TMDB.self) { response in
debugPrint(response) // <<<<<--- 이녀석이 물건임
switch response.result {
case .success(let success):
completionHandler(success)
case .failure(let fail):
print(fail)
}
}
}
[Request]: GET https://api.themoviedb.org/3/search/movie?language=ko-KR&page=0&query=marvel
[Headers]:
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI3MjJlNDYyYzdjY2I0ZmQ3YWQ5ZWM5MGE2OTNmNmMwNiIsInN1YiI6IjY1YTY5YTI3NTFhNjRlMDEyZTU0NmIyNSIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.9Er-Gap1LyDmYTLE5T2sYj-sYhZXrOm5kufV9REQ2-g
[Body]: None
[Response]:
[Status Code]: 400
[Headers]:
Alt-Svc: h3=":443"; ma=86400
Content-Length: 136
Content-Type: application/json;charset=utf-8
Date: Fri, 02 Feb 2024 13:06:54 GMT
Server: openresty
Vary: Origin
Via: 1.1 789fe305f22d3033b8114ffe7f407f2a.cloudfront.net (CloudFront)
x-amz-cf-id: _gn5VIsp00QHHiMGsxUHi2kVb-LnVkZ9FxfqVbCCeu7v_S-vk6R_ww==
x-amz-cf-pop: ICN55-C1
x-cache: Error from cloudfront
[Body]:
{"success":false,"status_code":22,"status_message":"Invalid page: Pages start at 1 and max at 500. They are expected to be an integer."}
[Network Duration]: 0.4775259494781494s
[Serialization Duration]: 0.00041508337017148733s
[Result]: failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.decodingFailed(error: Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "page", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"page\", intValue: nil) (\"page\").", underlyingError: nil)))))
한시간동안 못찾은 원인을 debugPrint를 사용하고나서 알았다. page가 1 이상이여야 query가 제대로 되는데, 0이 들어가고 있어서 계속 안되었었음
저녀석을 사용하지 않고 그냥 fail을 프린트 한거는 절대로 버그가 무엇인지 모르게 꽁꽁 숨겨서 보여준다.
responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.decodingFailed(error: Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "page", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"page\", intValue: nil) (\"page\").", underlyingError: nil))))