question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API and Storage modules not registered when calling `Amplify.configure`

See original GitHub issue

Describe the bug When using Amplify, I am unable to use Storage and API methods, and get respective errors (errors are below).

I am importing Amplify core package (@aws-amplify/core) and call the configure method like the following (code that is actually used):

import Amplify from '@aws-amplify/core'

Amplify.configure({
  Auth: {
    region: REGION,
    userPoolId: USER_POOL,
    identityPoolId: IDENTITY_POOL,
    userPoolWebClientId: USER_POOL_CLIENT
  },
  API: {
    endpoints: [
      {
        region: REGION,
        name: 'main',
        endpoint: API_ENDPOINT
      }
    ]
  },
  Storage: {
    AWSS3: {
      region: REGION,
      bucket: S3_BUCKET
    }
  }
})

Expected behavior The Storage and API modules should work as documented.

Desktop (please complete the following information):

  • OS: Fedora 30 (Linux)
  • Browser: Chrome 74

Package.json dependencies:

....
},
  "dependencies": {
    "@aws-amplify/api": "^1.0.36",
    "@aws-amplify/auth": "^1.2.25",
    "@aws-amplify/core": "^1.0.28",
    "@aws-amplify/storage": "^1.0.31",
    "@material-ui/core": "^3.9.3",
    "@reach/menu-button": "^0.1.18",
    "@reach/router": "^1.2.1",
    "@reach/tabs": "^0.1.6",
    "classcat": "^3.2.5",
    "draft-js": "^0.10.5",
    "prop-types": "^15.7.2",
    "query-string": "^6.7.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-helmet": "^5.2.1"
  },
...

Additional context React app, bundler is Parcel.


Log output: (the lines with Logging ... are from my code and log the Amplify object) Screenshot from 2019-06-20 17-06-33

After that when my app imports the API module (@aws-amplify/api), using the post method, I get an API not configured error. When importing and calling Storage.put, the error becomes:

Uncaught (in promise) TypeError: No plugin found in Storage for the provider
Uncaught (in promise) TypeError: Cannot read property 'put' of undefined

I suspect the API and Storage modules aren’t registered, because they still give null when logged (the “BEFORE” and “AFTER” logs in the screenshot above). I reinstalled the node_modules multiple times already to have a clean install.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
christiankaindlcommented, Jun 26, 2019

Thanks for the help everyone! I got it working, here is a short summary:

The Request failed with the status code 403 error was caused by a wrong path on the API call:

API.post('main', '/getPosts'); // wrong
API.post('main', 'getPosts'); // Correct

The Auth problem was fixed by updating all packages again and deleting + reinstalling node_modules. Also tested to use the Amplify.configure method (as I originally did) to configure the modules instead of doing them individually and it also works:

Amplify.configure({
  Auth: {
    region: REGION,
    userPoolId: USER_POOL,
    identityPoolId: IDENTITY_POOL,
    userPoolWebClientId: USER_POOL_CLIENT
  },
  API: {
    endpoints: [
      {
        region: REGION,
        name: 'main',
        endpoint: API_ENDPOINT
      }
    ]
  },
  Storage: {
    AWSS3: {
      region: REGION,
      bucket: S3_BUCKET
    }
  }
})

I updated the packages a week ago, and now again two days ago. Otherwise I have no idea what else fixed it ¯_(ツ)_/¯

Many thanks for your help @Magneticoz and @ssk690 ❤️

1reaction
Magneticozcommented, Jun 21, 2019

@christiankaindl, I just had the same problem. I’ve solved it on the way that I’ve separated configuration in my main.ts file.

So, instead of:

import Amplify from '@aws-amplify/core'

Amplify.configure({
  Auth: {
    region: REGION,
    userPoolId: USER_POOL,
    identityPoolId: IDENTITY_POOL,
    userPoolWebClientId: USER_POOL_CLIENT
  },
  API: {
    endpoints: [
      {
        region: REGION,
        name: 'main',
        endpoint: API_ENDPOINT
      }
    ]
  },
  Storage: {
    AWSS3: {
      region: REGION,
      bucket: S3_BUCKET
    }
  }
})

I did following:

import Storage from '@aws-amplify/storage';
import API from '@aws-amplify/api';
import Auth from '@aws-amplify/auth';

Auth.configure({
  Auth: {
    region: REGION,
    userPoolId: USER_POOL,
    identityPoolId: IDENTITY_POOL,
    userPoolWebClientId: USER_POOL_CLIENT
  }
});

API.configure({
  endpoints: [
    {
        region: REGION,
        name: 'main',
        endpoint: API_ENDPOINT
    }
  ]
});

Storage.configure(
  {
    AWSS3: {
      region: REGION,
      bucket: S3_BUCKET
    }
  }
);

Not sure if this is the best way of resolving it, but it did help in my case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter app throwing error while calling configure method of ...
In my flutter project, I'm using the AWS Amplify storage plugin to upload files. For that, ...
Read more >
Storage - Getting started - JavaScript - AWS Amplify Docs
AWS Amplify Storage module provides a simple mechanism for managing user content for your app in public, protected or private storage buckets.
Read more >
How to Add Authentication to a Vue App Using AWS Amplify
In this article, we're going to create a very simple Vue application using the Vue CLI. We'll modify the default scaffolded application so ......
Read more >
AWS Amplify + React Native / Authentication FULL SETUP
In this article, you'll learn how to correctly and securely implement authentication in a React Native application using Amazon Cognito with AWS Amplify....
Read more >
amplify-js
Storage.put with resumable turned on has changed the key to no longer include the ... + import { Amplify, Auth } from 'aws-amplify';...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found