Method is not a function #34

Open
opened 2016-11-03 06:43:31 +00:00 by labibramadhan · 3 comments
labibramadhan commented 2016-11-03 06:43:31 +00:00 (Migrated from github.com)

I have 3 models:

  • product with 1 field: name
  • category with 1 field: name
  • price with 1 field: price

Associations are:

  • product belongsTo category
  • product hasMany price
  • price belongsTo product

The problems are:
/api/v1/product/1/category route with { "name": "Category 1" } POST JSON data
and
/api/v1/product/1/price route with { "price": 10000 } POST JSON data
creates method is not a function error

Maybe the getMethod function inside src/utils.js called from inside create function inside src/associations/one-to-one.js cannot find the correct method, so its returns false.

Or maybe i missed something on my setup?

I have 3 models: * product with 1 field: name * category with 1 field: name * price with 1 field: price Associations are: * product belongsTo category * product hasMany price * price belongsTo product The problems are: `/api/v1/product/1/category` route with `{ "name": "Category 1" }` POST JSON data and `/api/v1/product/1/price` route with `{ "price": 10000 }` POST JSON data creates **method is not a function** error Maybe the **getMethod** function inside **src/utils.js** called from inside **create** function inside **src/associations/one-to-one.js** cannot find the correct method, so its returns false. Or maybe i missed something on my setup?
joeybaker commented 2016-11-03 17:27:13 +00:00 (Migrated from github.com)

Hi @labibramadhan If I understand you correctly, you're trying to create a new category that belongs to product with id=1. That's not currently something we support. But I would be happy to look at a pull request that adds that functionality.

In the meantime, you can always do:

POST /api/v1/category {"name": "Category 1", "productId": 1}

Hi @labibramadhan If I understand you correctly, you're trying to create a new category that belongs to `product` with `id=1`. That's not currently something we support. But I would be happy to look at a pull request that adds that functionality. In the meantime, you can always do: `POST /api/v1/category {"name": "Category 1", "productId": 1}`
labibramadhan commented 2016-11-04 03:18:42 +00:00 (Migrated from github.com)

@joeybaker ah i see, exactly i was trying to test the features based on README.MD

@joeybaker ah i see, exactly i was trying to test the features based on **README.MD**
joeybaker commented 2016-11-04 03:24:55 +00:00 (Migrated from github.com)

We'd happily take a PR that updates the README

We'd happily take a PR that updates the README
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: thereadme/hapi-sequelize-crud#34
No description provided.