Search code examples
error-handlingfeathersjsfeather

Feathers errors on a client side


My stack react/redux/redux-observable/immutablejs. Client is rendered by feathers.js using server side rendering. I use feather-client, after getting 400 (Request doesn't pass validation). I've got a response in .json format. But for some reasons it's converted to HTML or string.

Error: Order validation failed
    at BadRequest.ExtendableBuiltin (bundle.js:106696)
    at BadRequest.FeathersError (bundle.js:106771)
    at new BadRequest (bundle.js:106812)
    at convert (bundle.js:107040)
    at toError (bundle.js:106043) 

Any ideas how to disable it on a client?

import 'isomorphic-fetch';
import feathers from 'feathers-client';
import authentication from 'feathers-authentication-client';
import config from './config';

let storage = null;
if (!process.env.BROWSER && process.NODE_ENV !== 'test') {
  require('localstorage-polyfill');
  storage = global.localStorage;
}else{
  storage = window.localStorage;
}

const port = process.env.PORT || config.port;

promise.polyfill();

const rest = feathers.rest(`http://localhost:${port}/api`);
const app = feathers()
  .configure(feathers.hooks())
  .configure(rest.fetch(require('isomorphic-fetch')))
  .configure(authentication({ storage }));

export default app;

Solution

  • Spend some minutes fixing it, it's simply implement .toJSON() method...