Feathers: Socketio request send empty params.route

Created on 29 Aug 2019  路  2Comments  路  Source: feathersjs/feathers

Steps to reproduce

I have a Feathersjs API which using REST can serve a GET request to a URL like http://server.com/service-name/:fieldName where fieldName has a string value. The API assigns the value of fieldName to params.query.

While developing a React Native app, I am trying to make the same request using feathers socketio client. The request looks like this:

return this.app.service('service-name/:fieldName').find({
  query:{fieldName='value'}
}).then(response => {
  console.log('data from server', response.data); // ignore this console format
}).catch(error => {
  console.log(error);
});

After checking the logs on the API server, I found out that a REST API request has the correct params.route object:

object(9) {
    ["query"] => object(0) {}
    ["route"] => object(1) {
        ["fieldName"] => string(5) "value"
    }
    ...

The params.route is empty with the socketio request:

object(9) {
    ["query"] => object(0) {}
    ["route"] => object(0) {}
    ["connection"] => object(6) {
        ["provider"] => string(8) "socketio"
        ["payload"] => object(1) {
            ["userId"] => number(3)
        }
    ...

Could some please tell me how to correctly set params.route in React Native using a socketio request?

System configuration

Ubuntu 18.04.3 LTS

Module versions (especially the part that's not working):

API
feathers: 3.9.0

React Native
node: v8.10.0
npm: 6.10.0
react: 16.8.6,
react-native: 0.60.5
react-native-cli: 2.0.1
socket.io-client: ^2.2.0
feathers-hooks: ^2.1.2
feathers-hooks-common: ^4.20.7
feathers-socketio: ^2.0.1

Most helpful comment

I highly recommend updating your Node and Feathers version to the latest (you are using old module names from two versions ago) which allows to do what I already mentioned on Stackoverflow

return this.app.service('service-name/something').find({}).then(response => {
  console.log('data from server', response.data); // ignore this console format
}).catch(error => {
  console.log(error);
});

All 2 comments

I highly recommend updating your Node and Feathers version to the latest (you are using old module names from two versions ago) which allows to do what I already mentioned on Stackoverflow

return this.app.service('service-name/something').find({}).then(response => {
  console.log('data from server', response.data); // ignore this console format
}).catch(error => {
  console.log(error);
});

Thanks a lot @daffl . You are a hero!

Was this page helpful?
0 / 5 - 0 ratings