josx / ra-data-feathers

A feathers rest client for react-admin
MIT License
157 stars 53 forks source link

Cannot read property 'map' of undefined? #29

Closed tony-kerz closed 7 years ago

tony-kerz commented 7 years ago

hey man, thanks for writing this adapter!

i'm kind of new to aor and feathers, so it's entirely possible i'm just being a dunce, but i have this setup and i'm getting the above error in the browser when trying to do a simple list.

here are some relevant snippets:

const host = 'http://localhost:3000'

export default feathers() .configure(feathers.hooks()) .configure(feathers.rest(host).fetch(window.fetch.bind(window)))


- `app.js`

import React from 'react' import ErrorIcon from 'material-ui/svg-icons/alert/error' import {Admin, Resource} from 'admin-on-rest' import {restClient} from 'aor-feathers-client' import feathersClient from './feathers-client' import {AlertList} from './alerts' import Dashboard from './dashboard'

const options = {id: '_id'}

const App = () => <Admin dashboard={Dashboard} restClient={restClient(feathersClient, options)}>

export default App


- `alerts.js`

import React from 'react' import {List, Datagrid, TextField} from 'admin-on-rest'

// eslint-disable-next-line import/prefer-default-export export const AlertList = props => <List title="All alerts" {...props}>



- sample call to `http://localhost:3000/alerts` from browser

<img width="1213" alt="screen shot 2017-07-14 at 2 47 04 am" src="https://user-images.githubusercontent.com/1223231/28201484-3ff2b960-683f-11e7-8b21-78feeb455f36.png">

- some chrome debug output (i manually placed a `console.log` statement in aor saga code)

<img width="727" alt="screen shot 2017-07-14 at 2 56 34 am" src="https://user-images.githubusercontent.com/1223231/28201705-442dbbfa-6840-11e7-9cf4-8367069db93a.png">

> i'm not using any authentication yet, which is diff from examples given, wonder if that might be an issue, or not relevent

any troubleshooting suggestions appreciated!

best,
tony.
tony-kerz commented 7 years ago

doh! after some shut-eye noticed this on the server side:

  app:index "SequelizeBaseError: Unknown column 'Alert._id' in 'order clause'\n    at Query.formatError (/Users/tony/git/udx-api/node_modules/sequelize/lib/dialects/mysql/query.js:222:16)\n    at Query.connection.query [as onResult] (/Users/tony/git/udx-api/node_modules/sequelize/lib/dialects/mysql/query.js:55:23)\n    at Query.Command.execute (/Users/tony/git/udx-api/node_modules/mysql2/lib/commands/command.js:31:12)\n    at Connection.handlePacket (/Users/tony/git/udx-api/node_modules/mysql2/lib/connection.js:417:28)\n    at PacketParser.onPacket (/Users/tony/git/udx-api/node_modules/mysql2/lib/connection.js:93:16)\n    at PacketParser.executeStart (/Users/tony/git/udx-api/node_modules/mysql2/lib/packet_parser.js:73:14)\n    at Socket.<anonymous> (/Users/tony/git/udx-api/node_modules/mysql2/lib/connection.js:101:29)\n    at emitOne (events.js:115:13)\n    at Socket.emit (events.js:210:7)\n    at addChunk (_stream_readable.js:252:12)\n    at readableAddChunk (_stream_readable.js:239:11)\n    at Socket.Readable.push (_stream_readable.js:197:10)\n    at TCP.onread (net.js:589:20)" +1ms

used this for app.js:

import React from 'react'
import ErrorIcon from 'material-ui/svg-icons/alert/error'
import {Admin, Resource} from 'admin-on-rest'
import {restClient} from 'aor-feathers-client'
import feathersClient from './feathers-client'
import {AlertList} from './alerts'
import Dashboard from './dashboard'

// const options = {id: '_id'}

const App = () =>
  <Admin dashboard={Dashboard} restClient={restClient(feathersClient)}>
    <Resource name="alerts" list={AlertList} icon={ErrorIcon} />
  </Admin>

export default App

and voila:

screen shot 2017-07-14 at 9 24 11 am

so all good šŸ‘ thanks again for the adapter šŸ™