vizrtexample

Viz Engine REST API

Jul 18th, 2022 (edited)
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const vizPath = "http://127.0.0.1:61000";
  2.  
  3. async function getScene()
  4. {
  5.   const requestOptions = {
  6.         method: 'GET',
  7.         headers: {'Content-type': 'application/json'},
  8.   };
  9.   var response = await fetch(vizPath + "/api/v1/scene", requestOptions);
  10.   var data = await response.json();
  11.   return data;
  12. }
  13.  
  14. async function getSceneName(uuid)
  15. {
  16.   const requestOptions = {
  17.         method: 'GET',
  18.         headers: {'Content-type': 'application/json'},
  19.   };
  20.   var response = await fetch(vizPath + "/api/v1/scene/" + uuid + "/name", requestOptions);
  21.   var data = await response.json();
  22.   return data;
  23. }
  24.  
  25. function setSceneValue(uuid, field, value)
  26. {
  27.   const requestOptions = {
  28.         method: 'PUT',
  29.         headers:{'Content-type': 'application/json'},
  30.         body: JSON.stringify(value)
  31.   };
  32.   var response = fetch(vizPath + "/api/v1/scene/" + uuid + "/fields/" + field, requestOptions);
  33.   var data = response;
  34.   return data;
  35. }
  36.  
  37. getScene().then(data => console.log(data));
  38. getSceneName("1A011182-07B1-DA4A-9E86A3446C7DE189").then(data => console.log(data));
  39. setSceneValue("1A011182-07B1-DA4A-9E86A3446C7DE189", "1", "sample string");
  40.  
Add Comment
Please, Sign In to add comment