I’m trying to work through Chapter 20 and I’m stuck on page 359. The console prints:
{“stat”:“fail”,“code”:0,“message”:“Method “Flickr.interestingness.getList” not handled by library”}
I have a feeling the error is located in my FlickrAPI.swift file and its code is below:
import Foundation
enum Method: String {
case interestingPhotos = "Flickr.interestingness.getList"
}
struct FlickrAPI {
static var interestingPhotosURL: URL {
return flickrURL(method: .interestingPhotos, parameters: ["extras": "url_h,date_taken"])
}
private static let baseURLString = "https://api.flickr.com/services/rest"
private static let apiKey = "a6d819499131071f158fd740860a5a88"
private static func flickrURL(method: Method, parameters: [String:String]?) -> URL {
var components = URLComponents(string: baseURLString)!
var queryItems = [URLQueryItem]()
let baseParams = [
"method": method.rawValue,
"format": "json",
"nojsoncallback": "1",
"api_key": apiKey
]
for (key, value) in baseParams {
let item = URLQueryItem(name: key, value: value)
queryItems.append(item)
}
if let additionalParams = parameters {
for (key,value) in additionalParams {
let item = URLQueryItem(name: key, value: value)
queryItems.append(item)
}
}
components.queryItems = queryItems
return components.url!
}
}
What have I done wrong in the code? Many thanks in advance.