mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 10:01:55 +00:00
Merge pull request #1238 from balena-io/1237-device-id-on-fetch
Pass in deviceId when fetching device tags
This commit is contained in:
commit
abe1b59ebe
@ -383,8 +383,14 @@ export class APIBinder {
|
||||
'Attempt to communicate with API, without initialized client',
|
||||
);
|
||||
}
|
||||
|
||||
const deviceId = await this.config.get('deviceId');
|
||||
if (deviceId == null) {
|
||||
throw new Error('Attempt to retrieve device tags before provision');
|
||||
}
|
||||
const tags = (await this.balenaApi.get({
|
||||
resource: 'device_tag',
|
||||
id: deviceId,
|
||||
options: {
|
||||
$select: ['id', 'tag_key', 'value'],
|
||||
},
|
||||
|
@ -445,11 +445,18 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
|
||||
});
|
||||
|
||||
router.get('/v2/device/tags', async (_req, res) => {
|
||||
const tags = await applications.apiBinder.fetchDeviceTags();
|
||||
return res.json({
|
||||
status: 'success',
|
||||
tags,
|
||||
});
|
||||
try {
|
||||
const tags = await applications.apiBinder.fetchDeviceTags();
|
||||
return res.json({
|
||||
status: 'success',
|
||||
tags,
|
||||
});
|
||||
} catch (e) {
|
||||
res.status(500).json({
|
||||
status: 'failed',
|
||||
message: e.message,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/v2/cleanup-volumes', async (_req, res) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user