Created
July 9, 2018 10:55
-
-
Save rajajawahar/f62ded6d2f844e10cec4ad941c042119 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Alamofire | |
class APIManager: NSObject { | |
func getUsersList() -> [User]{ | |
var userList : [User] = [User]() | |
Alamofire.request("https://api.github.com/users") | |
.responseJSON { response in | |
do { | |
let decoder = JSONDecoder() | |
let user = try decoder.decode([User].self, from: response.data!) | |
userList.append(contentsOf: user) | |
} catch let err { | |
print("Err", err) | |
} | |
} | |
return userList | |
} | |
func getReposList(url : String) -> [Repos]{ | |
var userList : [Repos] = [Repos]() | |
Alamofire.request(url) | |
.responseJSON { response in | |
do { | |
let decoder = JSONDecoder() | |
let user = try decoder.decode([Repos].self, from: response.data!) | |
userList.append(contentsOf: user) | |
} catch let err { | |
print("Err", err) | |
} | |
} | |
return userList | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment