Complete the code to enable observation of a resource for notifications.
client.observe([1], onNotification);The observe method requires the resource path to start observing notifications.
Complete the code to handle notifications when observing a resource.
function onNotification([1]) { console.log('Notification received:', data); }
The callback receives the notification data as the first argument, commonly named data.
Fix the error in the code to correctly start observing notifications.
client.[1]('sensor/temp', onNotification);
The correct method to start observation is observe. Other methods like notify or subscribe are incorrect here.
Fill both blanks to create an observe request with options for notifications.
client.observe('[1]', { [2]: true }, onNotification);
The resource path is 'sensor/humidity' and the option to make notifications confirmable is 'confirmable: true'.
Fill all three blanks to correctly observe a resource with options and handle notifications.
client.observe('[1]', { [2]: true, [3]: 30 }, onNotification);
The resource is 'sensor/light', the notifications are confirmable, and maxAge sets the max age of cached data.
