0

I'm attempting to fetch a json from my path. And everything seems right (granted I came from Swift 2 and tried updating to Swift 4) however, things seem to have gone awry.

class func getPlayerStatuses(sportName: String) -> Promise<[NSDictionary]> {
    let path = "api/sports/player-status/\(sportName)/"
    return API.get(path).then { (json: NSDictionary) -> [NSDictionary] in
        let playerUpdates: [NSDictionary] = try json.get("player_updates")
        return playerUpdates
    }
}

And I'm receiving the following error.

Cannot convert value of type '(NSDictionary) throws -> [NSDictionary]' to expected argument type '(_) throws -> _'

Does anyone have any clues as to why I'm getting errors about type conversion?

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Konrad Wright
  • 1,254
  • 11
  • 24

1 Answers1

1

The way of returning non-promise value changed in PMK 6 (see Why PromiseKit 5/6? section). Now you should use map instead of then for this kind of work.

pacification
  • 5,838
  • 4
  • 29
  • 51