Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. const CheckSource = async function(AttId, symbolId){
  2.  
  3. //creates the get parameters
  4. var SourceGetParams = Helper.returnGetOptions(`SignalValues/${symbolId}/${AttId}`);
  5.  
  6. //send the get request and waits for responce
  7. await Helper.sendRequest(SourceGetParams).then((res, body) => {
  8.  
  9. //parses the response, prints the correct value, but returns "undefined"
  10. var response_body = JSON.parse(res.body);
  11. var value = response_body.API_Signals[0].RawValue
  12. console.log(value);
  13. return Promise.resolve(value);
  14.  
  15. //error handling
  16. }, (error) => {
  17. console.log('error sending source get request:', error);
  18. return Promise.reject('There was an error with the fusion request.');
  19. }).catch((error) => {
  20. console.log('Source sendRequest promise error:', error);
  21. return Promise.reject('There was an internal error sending the request.');
  22. }); }
  23.  
  24. CheckSource(<Att_ID string here>, <Symbol_ID string here>).then((data)=>{
  25. console.log(data)
  26. });
  27.  
  28. False //(this is the expected output from the conslole.log() in the async function)
  29.  
  30. undefined //(this is the console.log() after I called the function)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement