In my AWS project, I created webservices using Lambda and API Gateway. Those webservices are called by my iOS app, using the Amplify framework.
In my lambda functions:
- I return something like the following when there is no error:
return {
statusCode: 200,
body: JSON.stringify({
"example_key_1": "example_value",
"example_key_2": 123456789
})
};
- I return something like the following when there is an error:
return {
statusCode: 400,
body: JSON.stringify({
"custom_error_code": 333333
})
};
And from my iOS app, I call my API by doing something like the following:
Amplify.API.post(request: request) { result in
switch result
{
case .success(let data):
print("success: \(data)")
case .failure(let error):
print("error: \(error)"
}
}
Now, here are the infos I need to get from the response of the API:
- the status code, when there is an error
- the body of the response, whether there is an error or not
In other words, I need to get in my iOS app the whole content of each return
of the lambda, when I call the API.
It seems easily doable with the Amplify framework for Javascript, according to this, but I can't find the equivalent for iOS or Android.
How can I achieve that with the Amplify framework?
Thanks.
Amplify Android
Amplify iOS