Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const device = new iothub.Device(null);
device.deviceId = devEUI;
this.registry.create(device, (err, deviceInfo) => {
if (!err) {
resolve(deviceInfo);
} else {
// The device probably exists
this.registry.get(device.deviceId, (err, deviceInfo) => {
if (err) {
reject(err);
} else {
resolve(deviceInfo);
}
});
}
});
}).then(deviceInfo => {
return new Promise((resolve, reject) => {
const device = new iothub.Device(null)
device.deviceId = deviceId
this.registry.create(device, (err, deviceInfo) => {
if (err) {
// The device probably exists
this.registry.get(device.deviceId, (err, deviceInfo) => {
if (err) {
reject(err)
} else {
resolve(deviceInfo)
}
})
} else {
resolve(deviceInfo)
}
})
}).then(deviceInfo => {