Being able to make any request after login. Can't initialize data in request() -> urlSession.dataTask
Actual Behavior
Error when invoking api.userFollows(...):
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Error when invoking getInstagramData()=api.user(...):
decoding(message: "The data couldn’t be read because it is missing.") The operation couldn’t be completed. (SwiftInstagram.InstagramError error 0.)
Steps to Reproduce the Problem
Login button action
`
static func loginInstagram(from: UINavigationController, completion: @escaping (Error?) -> Void){
let api = Instagram.shared
`
static func getInstagramData() {
let api = Instagram.shared
api.user("self", success: { userList in
print(SwiftyJSON.JSON(userList))
}, failure: { error in
print(error)
print(error.localizedDescription)
})
}
`
However this works:
Alamofire.request("https://api.instagram.com/v1/users/self?access_token="+api.retrieveAccessToken()!).responseJSON(completionHandler: { response in if let result = response.result.value { let swiftyJSON = JSON(result) print(swiftyJSON) }
Checklist
Expected Behavior
Being able to make any request after login. Can't initialize data in request() -> urlSession.dataTask
Actual Behavior
Error when invoking api.userFollows(...):
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Error when invoking getInstagramData()=api.user(...):decoding(message: "The data couldn’t be read because it is missing.") The operation couldn’t be completed. (SwiftInstagram.InstagramError error 0.)
Steps to Reproduce the Problem
` static func loginInstagram(from: UINavigationController, completion: @escaping (Error?) -> Void){ let api = Instagram.shared
} `
` static func getInstagramData() { let api = Instagram.shared
} `
However this works:
Alamofire.request("https://api.instagram.com/v1/users/self?access_token="+api.retrieveAccessToken()!).responseJSON(completionHandler: { response in if let result = response.result.value { let swiftyJSON = JSON(result) print(swiftyJSON) }
Specifications