Skip to content
This repository was archived by the owner on Oct 14, 2018. It is now read-only.
This repository was archived by the owner on Oct 14, 2018. It is now read-only.

Unable to make requests #49

@blackwiz4rd

Description

@blackwiz4rd

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

  1. Login button action

`
static func loginInstagram(from: UINavigationController, completion: @escaping (Error?) -> Void){
let api = Instagram.shared

    // Login
    //print("Instragam Login")
    api.login(from: from, withScopes: [.basic, .publicContent], success: {
        completion(nil)
    }, failure: { error in
        print(error.localizedDescription)
    })

}
`
2. Get data button action

`
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) }

Specifications

  • iOS Version:latest
  • Device(s):all iOS devices

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions