moqada / simple-api-client-generator

API Client Generator from JSON Hyper Schema
MIT License
2 stars 3 forks source link

Generated method does not binding this #28

Closed ideyuta closed 7 years ago

ideyuta commented 7 years ago

Generated method does not binding this. So, can't access the simple-api-client methods.

I changed it to bind this, so check it.

Now

export default class APIClient extends SimpleAPIClient {
  userCreate() {
    ...
    this.post(path, opts);  // this.post is undefined
  }
}

Fixed

export default class APIClient extends SimpleAPIClient {
  userCreate = () => {
    ...
    this.post(path, opts);  // LGTM
  }
}

cc @moqada

ideyuta commented 7 years ago

@moqada

This problem concerns the design around bind, so we withdraw once. 😭