Tuesday, September 6, 2016

Uncaught TypeError: client(...).done is not a function

When you use `rest` as follows:

    client({
      method: 'GET',
      path: '/api/employees'
    }).done(response => {
      this.setState({
        employees: response.entity._embedded.employees
      });
    });

you might get the following error:

Uncaught TypeError: client(...).done is not a function

Changing `done()` to `then()` as follows fixes the error:

    client({
      method: 'GET',
      path: '/api/employees'
    }).then(response => {
      this.setState({
        employees: response.entity._embedded.employees
      });
    });

Reference:
https://github.com/cujojs/rest

No comments:

Post a Comment