dcaputo-harmoni / open-balena-admin

Open Balena Admin
MIT License
91 stars 18 forks source link

Can't create Device Type #10

Closed markdegrootnl closed 2 years ago

markdegrootnl commented 2 years ago

When I try to create new Device Type, I get the following error in the console: TypeError: Cannot read properties of undefined (reading 'id')

This is probably due to: https://github.com/dcaputo-harmoni/open-balena-ui/blob/a464227e69f50524ce02a0e0c17b6af328cf4a28/src/lib/deviceType.js#L11 which i Think should be: const deviceType = await dataProvider.create('device type', {data: data});

However if I change this, I'm still getting a different error: JSON object requested, multiple (or no) rows returned

The Device Type and Device Type Alias do get created, but after the request it tries to do another POST request to /device type with null as data, which seems to be the result of the return null in the useCreateDeviceType() function.

dcaputo-harmoni commented 2 years ago

You are correct - nice catch! As you pointed out it should still work, but will result in an error message being displayed. I'll push the change now.