Skip to content
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

Signer.sign({body:"hello"}, {method:"POST"}) should use body attribute like fetch() #9863

Closed
3 tasks done
maxerbubba opened this issue May 2, 2022 · 5 comments
Closed
3 tasks done
Assignees
Labels
Auth Related to Auth components/category Core Related to core Amplify issues feature-request Request a new feature good first issue Good for newcomers help wanted With this label, this allows anyone looking for help from the community of Amplify TypeScript Related to TypeScript issues Utilities Related to Utility issues

Comments

@maxerbubba
Copy link

maxerbubba commented May 2, 2022

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

Typescript page, with React, and I am using the Signer.sign() library directly (Sorry not using the full Amplify toolset)

import { Signer } from 'aws-amplify';

Describe the bug

  1. Run this code
Signer.sign({body:"hello"}, {method:"POST"}); // <---- Notice body attribute, where API docs use data.
  1. output:
headers: Content-Length: 0

Expected behavior

One possible solution:

headers: Content-Length: 5

Another possible solution:

throw "attribute `body` found in Signer, but `data` is missing. Please use attribute `data`"

Reproduction steps

create-react-app
import { Signer } from 'aws-amplify';
Signer.sign({body:"hello"}, {method:"POST"})

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@chrisbonifacio chrisbonifacio added Utilities Related to Utility issues pending-triage Issue is pending triage feature-request Request a new feature labels May 13, 2022
@abdallahshaban557 abdallahshaban557 added the Auth Related to Auth components/category label May 16, 2022
@nickarocho nickarocho added the TypeScript Related to TypeScript issues label May 17, 2022
@stocaaro stocaaro added the Core Related to core Amplify issues label May 17, 2022
@chrisbonifacio chrisbonifacio added help wanted With this label, this allows anyone looking for help from the community of Amplify good first issue Good for newcomers labels Jun 8, 2022
@chrisbonifacio chrisbonifacio added this to To do in MLH Fellows Summer 2022 via automation Jun 8, 2022
@chrisbonifacio chrisbonifacio removed the pending-triage Issue is pending triage label Jul 13, 2022
@chrisbonifacio chrisbonifacio moved this from To do to In progress in MLH Fellows Summer 2022 Jul 13, 2022
@ahilashsasidharan
Copy link

ahilashsasidharan commented Jul 16, 2022

@maxerbubba I was looking for clarification in the exact code you ran to get the error. As far as I can tell your code seems to be a more reduced version of code sent to the sign method is it possible to send a more detailed code snippet as sending just the code you sent with the two objects results in an error due to missing information, or some more detail in exactly what you would like implemented. Also could you provide some clarification on the second possible solutionthrow "attribute `body` found in Signer, but `data` is missing. Please use attribute `body`" on what you would like implemented for this solution to work.

@maxerbubba
Copy link
Author

Whoops, I meant to put "data". (I edited the message above)

throw "attribute `body` found in Signer, but `data` is missing. Please use attribute `data`"

I was frustrated. This is just a convenience, to compare to similar libraries. I was initially using fetch(), and then was trying to switch to AmplifyJS signer, and my old code still had body.

Adding a little type checking on the input object would be nice for developers to find bugs faster.

@ahilashsasidharan
Copy link

@maxerbubba So, if I understand correctly, you want to ensure that a body sent in the request object will be treated the same as sending data. Or you want an error thrown when there is a body in the request object but not a data attribute. Is there a preference between the two, or am I not getting what you want correct?

@maxerbubba
Copy link
Author

maxerbubba commented Jul 20, 2022 via email

@chrisbonifacio
Copy link
Contributor

Closing this as it has been fixed by #10137

Thank you, @amehi0index ! 🚀

@chrisbonifacio chrisbonifacio moved this from In progress to Done in MLH Fellows Summer 2022 Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category Core Related to core Amplify issues feature-request Request a new feature good first issue Good for newcomers help wanted With this label, this allows anyone looking for help from the community of Amplify TypeScript Related to TypeScript issues Utilities Related to Utility issues
Development

No branches or pull requests

7 participants