undefined error on first query
Closed this issue ยท 3 comments
markusleh commented
I've followed AWS's Amplify tutorial as well as your and react-admin tutorials.
Here is my App.js
import { Amplify } from "@aws-amplify/core";
import React from "react";
import { Resource, ListGuesser, Admin } from "react-admin";
import { buildDataProvider } from "react-admin-amplify";
import awsExports from "./aws-exports";
import * as mutations from "./graphql/mutations";
import * as queries from "./graphql/queries";
Amplify.configure(awsExports); // Configure Amplify the usual way
function App() {
return (
<Admin // Replace the Admin component of react-admin
dataProvider={buildDataProvider({ queries, mutations })}
>
<Resource name="todos" list={ListGuesser} />
</Admin>
);
}
export default App;
In my models I have
type Todo @model {
id: ID!
name: String!
description: String
}
However, upon running the application http://localhost:3000/#/todos
I get no results, the loader spinner keeps spinning and there is a following message on console:
MrHertal commented
Hi,
Your code looks fine.
Did you add the Auth
category on your Amplify backend?
You may need to change the authMode option.
It is set to AMAZON_COGNITO_USER_POOLS
by default but it looks like your API is public.
You may try API_KEY
instead.
markusleh commented
Ah, that was it. Thank you!
This works:
<Admin
dataProvider={buildDataProvider({queries, mutations}, {authMode: "API_KEY"})}
>
I'm wondering where that error message is coming from? react-admin? Why would it show up us just undefined