You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You aren't validating the response status code, so it is possible that a 404 will return you a .Success case. All that the responseData serializer does is validate that there wasn't an error (which there won't be since you aren't validating the response status code) or that the data exists.
publicstaticfunc dataResponseSerializer()->ResponseSerializer<NSData,NSError>{returnResponseSerializer{ _, _, data, error in
guard error ==nilelse{return.Failure(error!)}
guard let validData = data where validData.length >0else{letfailureReason="Data could not be serialized. Input data was nil or zero length."leterror=Error.errorWithCode(.DataSerializationFailed, failureReason: failureReason)return.Failure(error)}return.Success(validData)}}
In your case, you are receiving a 404 which isn't throwing an error, and the server is returning data. Therefore, your responseData serializer succeeds. If you expect a 404 to always throw an error, you should additionally use the .validate(statusCode: [200]) method before the responseData serializer. More info in the Validation Section of the README.
In the future, questions like this are better suited for Stack Overflow with an alamofire tag. We use GitHub for bugs and feature requests. 🍻
We don't use GitHub as a support forum. For any usage questions that are not specific to the project itself, please ask on Stack Overflow instead. By doing so, you'll be more likely to quickly solve your problem, and you'll allow anyone else with the same question to find the answer. This also allows maintainers to focus on improving the project for others.
The text was updated successfully, but these errors were encountered: