prismicio / javascript-kit

Development kit for the Javascript language
https://developers.prismic.io
106 stars 69 forks source link

Json response might contain key with value null #152

Closed valstu closed 7 years ago

valstu commented 7 years ago

Noticed a bug, there's also discussion about his on Slack. https://prismic-club.slack.com/archives/C44PCQE3Z/p1493300281846013

Let say I have a title and content fields, the json response from prismic contains key value pair like this

...
title: "This is page title",
content: "Lorem ipsum....",
...

If I remove the content through admin UI the new response contains only this:

...
title: "This is page title",
...

This is the expected feature. But there’s a bug inside new slices feature. Let say the same fields as above are inside new Slice repeat field. And I have content on both fields the response is as expected:

...
title: "This is page title",
content: "Lorem ipsum....",
...

But if I remove the content through admin ui, the json response is like this:

...
title: "This is page title",
content: null
...

This causes problems on javascript-kit library since the initField function on fragments.js (L:1216) expects that there’s always a value for this key.

valstu commented 7 years ago

Made a PR #153

valstu commented 7 years ago

This will be fixed on the backend. Check: https://github.com/prismicio/javascript-kit/pull/153#issuecomment-299148821.

Closing this issue for now.