Closed motivus closed 5 years ago
Just a note that I "grabbed the defaultClient" (to quote the README.md) by calling the default
() function in <myApiName>Client.swift
as follows:
@IBAction func userInvokeApi(_ sender: UIButton) {
print("You clicked invoke api...")
// grab the defaultClient...
let client = SVTLambdaGateClient.default()
client.calcGet(operand2: "3", _operator: "+", operand1: "5").continueWith{ (task: AWSTask?) -> AnyObject? in
if let error = task?.error {
print("Error occurred: \(error)")
return nil
}
if let result = task?.result {
// Do something with result
print("Result was returned from REST API")
}
return nil
}
}
And my REST API was successfully called, as confirmed in the Cloudwatch logs!
Is this what the README.md meant to do?
I'm going to post another usage question about how to access the result because I'm having trouble figuring out what to do with the AWSTask type.
Hello @motivus
Thanks for pointing out this error to us. You are right, the README
intents to use the .default()
and not defaultClient()
Also, as a reference point, we have updated documentation set here which uses the latest SDK versions and best practices: https://aws-amplify.github.io/docs/ios/api#rest-api
The link you have pointed out is a little old.
Best, Rohan
Thank you, Sir! Updating my reply here because I see that you linked to the REST API section of the new Amplify documentation. That's actually where I started a couple months ago... but I've had some trouble controlling how Amplify generates backend resources, so I switched to using the AWS docs to create my resources. That's why I linked the API Gateway tutorial / docs. No need to reply!
I don't understand why that thread is closed, since that problem is still here, almost 2 years later...
Describe the bug There is noClient.swift as per the directions in
defaultClient
in the API Gateway-generatedREADME.md
.To Reproduce Steps to reproduce the behavior:
I followed this REST API tutorial in the API Gateway docs. It's a simple API named 'calc' that calls a Lambda function that performs the calculation. It works perfectly in test invocations via the APIG console.
I generated an iOS Swift SDK as instructed here in the docs and followed the instructions for use in my simple iOS project. The problem is that
README.md
states that I should "grab thedefaultClient
from your code"... but there is NO defaultClient in the generated<myApiName>Client.swift
.The only references to
defaultClient
(or close) in<myApiName>Client.swift
is as follows:and then just below:
I assume I should be looking for a
public class func defaultClient()
, right?Which AWS service(s) are affected? API Gateway
Expected behavior I would expect the the API Gateway-generated iOS Swift SDK would have a
defaultClient()
function in<myApiName>Client.swift
if the README states that the developer should use it in their iOS app.Screenshots If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
Device Information (please complete the following information):