-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API name is invalid. #12744
Comments
Hi @zayeemZaki it looks like you're using Amplify v6. Can you try changing your post request's syntax to this? const response = await post({
apiName: "stripeAPI",
path: "/checkout",
options: {
body: { cart },
},
}); It looks like you have a a lot of scoped amplify packages installed, such as Having You should only need import { post } from `aws-amplify/api` |
@chrisbonifacio Thank you that fixed the apiName invalid error but now I'm getting two errors: |
That might be due to an existing bug regarding unrestricted REST APIs. If yours is unrestricted, you can try adding an arbitrary Authorization header until the fix is published. const response = await post({
apiName: "stripeAPI",
path: "/checkout",
options: {
headers: {
Authorization: 'test'
},
body: {
cart
},
},
}); If your API is not restricted then Amplify should be setting those headers automatically or you may need to pass the credentials your API expects. |
Thank you it fixed NoCredentials error but I'm still getting : This is my lambda function:
|
Okay so one last thing, to get the data from your API's response, use this syntax
Here are our docs on making REST API calls and accessing the response payload https://docs.amplify.aws/react/build-a-backend/restapi/fetch-data/#accessing-response-payload |
Thank you for your help, I figured it out! |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
REST API
Amplify Categories
function, api
Environment information
Describe the bug
I am trying to send request to stripe using Rest Api and lambda but when I click on checkout button it says ApiName is invalid even though the apiName is correct
Expected behavior
After clicking on checkout button, I want it to send request to Rest API which should call amplify lambda funciton and load stripe checkout page to display back to user
Reproduction steps
By clicking on checkout button.
Code Snippet
// Put your code below this line.
//handleCheckOut is called when user clicks on checkout button
//Index.js
aws-exports.js
The text was updated successfully, but these errors were encountered: