Wikodit / js-data-jsonapi-light

JSData adapter which serialize and deserialize JSONApi response and requests.
MIT License
8 stars 4 forks source link

Create method with wrong parameters format #14

Closed Pixhart closed 7 years ago

Pixhart commented 7 years ago
store.create('CourseCompetency', {
        categoryId: '437aefd3-698d-4d83-a385-dd69943447f1',
        title: 'eazazeazeaz',
        type: 'theorical'
      })

This should be the way you specify object's parameters. It's not working and return an error :

POST http://127.0.0.1:3000/api/course-competencies 422 (Unprocessable Entity) errors.detail = JSON API resource object must contain data property

Right now, it's working if we add data, data.type, and data.attributes :

store.create('CourseCompetency', {
        data: {
          type: 'CourseCompetency',
          attributes: {
            categoryId: '437aefd3-698d-4d83-a385-dd69943447f1',
            title: 'eazazeazeaz',
            type: 'theorical'
          }
        }
})
Tronix117 commented 7 years ago

Yes, I will address that ref: http://jsonapi.org/format/#crud

Tronix117 commented 7 years ago

Are you sure you have the latest build ? It should behave correctly, it was handled by #11

Check the unit test here: https://github.com/Wikodit/js-data-jsonapi-light/blob/develop/test/unit/crud/create.spec.ts#L45-L68

Tronix117 commented 7 years ago

After investigation, nothing is wrong, it's more likely due to the use with an API that doesn't support UPDATE, it will be fixed by #9