I realize Alamofire 5 is not yet out, but when doing some testing with 5.0.0.rc2, a GraphQL request will result in a crash:
return request.responseJSON { response in
.
.
.
}.task!
Unexpectedly found nil while unwrapping an Optional value
After running through the debugger, task isn't always created right away.
As a temporary hack solution, I added a usleep:
let request = sessionManager
.request(url, method: .post, parameters: body,
encoding: JSONEncoding.default, headers: headers)
.validate(statusCode: [200])
usleep(500)
if loggingEnabled {
debugPrint(request)
}
Has anyone else experienced this?