Get device status (JavaScript)

The following code example gets the status of all devices in your emnify account:

1function getDeviceStatus(){
2 fetch(`https://cdn.emnify.net/api/v1/endpoint`, {
3 method: 'GET',
4 headers: {
5 "accept": "application/json",
6 "Authorization": `Bearer AUTH_TOKEN`
7 }
8 })
9 .then(result => result.json())
10 .then(result => {
11 console.log(result)
12 })
13}

The result looks something like this:

1[
2 {
3 id: 11180765,
4 name: 'Test_device231', // Device Name
5 tags: 'dashboard',
6 created: '2021-06-24T19:02:43.000+0000',
7 last_updated: '2021-06-24T19:02:49.000+0000',
8 status: {
9 id: 0,
10 description: 'Enabled'
11 },
12 service_profile: {
13 id: 421239,
14 name: 'Generic Service Profile'
15 },
16 tariff_profile: {
17 id: 409292,
18 name: 'Generic Tariff Profile'
19 },
20 sim: {
21 id: 3991447,
22 iccid: '898830300000***9680',
23 imsi: '2950509****1169',
24 msisdn: '423**39212***74'
25 },
26 imei: **********,
27 ip_address: '100.**.*.***',
28 ip_address_space: {
29 id: 6808
30 },
31 imei_lock: false
32 }
33]