It looks like I am missing something in my setup. I'm getting a vague and general error as I attempt to retrieve a resource with
api.service('listings').find()
The same counts for finding users
The error is:
Unexpected token < in JSON
I can't find out whether somewhere I'm not parsing or whether the service methods themselves are not available yet. Starting the server with DEBUG=feathers* npm start
doesn't give me much clues. I am able to login and receive post requests using curl though. What am I missing?
This is part of my Api class:
class API {
constructor() {
this.app = feathers()
.configure(feathers.hooks())
.configure(feathers.rest().fetch(fetch))
}
service(serviceName) {
return this.app.service(serviceName)
}
This is part of my app.js:
app.use(compress())
.use(bodyParser.json())
.use(bodyParser.urlencoded({ extended: true }))
Are the service methods always available after scaffolding a REST app? For the apps where I used sockets they were instantly available I believe. Does fetch (or something similar) do this for me? Or should I define everything myself e.g. like so:
const service = require('feathers-sequelize')
const myService = {
find(params [, callback]) {},
get(id, params [, callback]) {},
create(data, params [, callback]) {},
update(id, data, params [, callback]) {},
patch(id, data, params [, callback]) {},
remove(id, params [, callback]) {},
setup(app, path) {}
}
app.use('/listings', myService)
Help would be greatly appreciated!
I was doing
before I was configuring services and middleware with
.configure(services)
and.configure(middleware)
. That's not right. The order should be reversed.