GithubHelp home page GithubHelp logo

Comments (3)

jimblanc avatar jimblanc commented on June 3, 2024

@Rajan-Gupta1 Thank you for your report! Are you trying to use Amplify JS v6? You should be able to use RXJS' from utility on the response promise, for example:

const getOperation = get('apiName', '/getData');
return from(getOperation.response);

from amplify-js.

Rajan-Gupta1 avatar Rajan-Gupta1 commented on June 3, 2024

@jimblanc Thanks for your response. The challenge I am having is that it is forcing me to make the function async since now I am unable to provide the Authorization token in awsconfig in the configuration like I was able to like this:
{
name: "chimeAPI",
endpoint: environment.medBodyCareAPI_endpoint,
custom_header: async () => {
return { Authorization: Bearer ${(await Auth.currentSession()).getIdToken().getJwtToken()} }
}
},
Now I am having to provide get the idToken as await
const authToken = (await fetchAuthSession()).tokens?.idToken?.toString();
which is making me mark the function async.
How do you suggest that your above suggestion will work when authorization token is needed and an observable using from must be returned?

from amplify-js.

cwomack avatar cwomack commented on June 3, 2024

@Rajan-Gupta1, did you only experience this when upgrading to v6? And can you provide any context on why you're not looking to have the functions async?

You can get the tokens needed elsewhere for your custom header (using await) or convert your function to async. But I don't think there's going to be a way around making things async/await if I'm understanding your use case properly.

from amplify-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.