Interacting with devices – hands-on with the Node.js SDK
In this section, we are going to get hands-on and practical with devices. We will perform CRUD operations on a device as well as listing all the devices and showing all the parameters of specific devices. Open up VSCode and navigate to this chapter’s example code. Then click on the device
folder: here you can find all the code related to device operations.
Creating a device
Firstly, we will start with device creation. The documentation on device creation can be found at https://www.arduino.cc/reference/en/iot/api/#api-DevicesV2-devicesV2Create. Open create-device.js
under the device
folder in VSCode.
There are two methods in the code: one is getToken()
, which is the same method as in all our coding exercises and helps us to fetch the authentication token for requests. The second method is CreateDevice()
, which is responsible for device creation. Consulting the documentation, we can see we need to initiate...