kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

Retrieve a content type element throws error #373

Closed Nabelops closed 1 year ago

Nabelops commented 1 year ago

Brief bug description

https://kontent.ai/learn/docs/apis/openapi/delivery-api/#operation/retrieve-a-content-type-element

ERROR TypeError: Cannot read properties of undefined (reading 'codename')

Repro steps

  1. Query for an element this.client.element('whatever', 'category'), this element is a multi-choice
  2. generic-element.mapper.js seems to be the source of the error.

Response does not seem to be an object with an property of element

{
    "type": "multiple_choice",
    "name": "category",
    "options": [
        {
            "name": "thing",
            "codename": "thing"
        },
        {
            "name": "another thing",
            "codename": "another_thing"
        }
    ],
    "codename": "category"
}

Expected behavior

Returns an an element

Test environment

Additional context

We use it to help sort things by the multiple choice field. E.g. Nav sub menu of the categories multi-choice.

Screenshots

Add links to screenshots, if possible.

Enngage commented 1 year ago

Hi @Nabelops,

There was a change in the API which caused this to happen. We've updated this SDK and it should work correctly in v 14.4.0.