blob: 116a8790fa25357a88e99c040abf220b09ac126f [file] [log] [blame]
Andrea Campanella362b7d32018-12-11 18:57:12 +01001export function getDevices() {
2
3 return new Promise((resolve, reject) => {
4 fetch(`/onos/devices`, {
5 method: 'GET',
6 })
7 .then(res => {
8 if (res.ok) {
9 res.json().then(data => resolve(data["devices"]))
10 } else {
11 reject(res.text())
12 }
13 })
14 .catch(err => {
15 console.error(err)
16 })
17 })
18}
19
20export function getPorts(devices) {
21
22 return new Promise((resolve, reject) => {
23 fetch(`/onos/devices/${devices}/ports`, {
24 method: 'GET',
25 })
26 .then(res => {
27 if (res.ok) {
28 res.json().then(data => resolve(data))
29 } else {
30 reject(res.text())
31 }
32 })
33 .catch(err => {
34 console.error(err)
35 })
36 })
37}