Open Darrow8 opened 4 years ago
Hi Darrow8,
I recommend taking a closer look at Creating promises.
return Promise {
return nil
}
This is not a valid declaration.
It should Either be
return Promise { () -> Any
return yourAnyObject
}
or
return Promise<Any> { fulfill, reject in
fulfill(yourAnyObject)
}
If you want to return nil, then your Promise type should be Promise<Any?>
.
p.s. Seeing by your code, you don't want to return anything but would just like to be notified when done. So why not use Promise<Void>
type for that. Also, I think what you want is this. Put the code you want to run asynchronously inside the closure.
func uploadUsers(arr1: Array<String>, arr2: Array<String>) -> Promise<Void> {
return Promise { () -> Void in
for usCount in 0..<(arr1.count){
print("USERNAME\(arr1[usCount] as! String)")
print("EMAIL\(arr2[usCount] as! String)")
}
return ()
}
}
getAllUsers(gsuiteName: gsuiteName).then(uploadUsers(arr1: currentUsersEM,arr2: currentUsersUS)).then(newScreen())
Am trying to use this library for the first time and am running into this error when chaining promises together:
Here is the code for getAllUsers() and uploadUsers(): ` func getAllUsers(gsuiteName: String) -> Promise{