aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

API not having authentication from Amplify #183

Closed vsrivatsan89 closed 6 years ago

vsrivatsan89 commented 6 years ago

I have downloaded the aws-exports.js from my mobilehub console and initialized Amplify with Amplify.configure('./Path/to/exports.js');Then in another component when I do

let apiName = 'UsersCrud'; 
    let path = '/Users'; 
    let myInit = {
      body: {
        "userId": "5",
        "Name": "test"
      }

    }

    API.post(apiName, path, myInit).then(response => {
      console.log("Response:" + response)
    }).catch(err => {
      console.log("Error:" + err)
    });

I see an Error No Credentials. What piece am I missing? I've read the docs and seem to be stuck.

vsrivatsan89 commented 6 years ago

Also notice this in the stacktrace. "Cannot read property 'accessKeyId' of null"

vsrivatsan89 commented 6 years ago

The issue is back. I don't know what I changed.

vsrivatsan89 commented 6 years ago

I'm very sorry for my back and forth. The localStorage on the browser I was testing with had a stale data. Once I cleared it out and and "logged in" with AWS cognito, everything worked fine.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.