Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const CheckSource = async function(AttId, symbolId){
- //creates the get parameters
- var SourceGetParams = Helper.returnGetOptions(`SignalValues/${symbolId}/${AttId}`);
- //send the get request and waits for responce
- await Helper.sendRequest(SourceGetParams).then((res, body) => {
- //parses the response, prints the correct value, but returns "undefined"
- var response_body = JSON.parse(res.body);
- var value = response_body.API_Signals[0].RawValue
- console.log(value);
- return Promise.resolve(value);
- //error handling
- }, (error) => {
- console.log('error sending source get request:', error);
- return Promise.reject('There was an error with the fusion request.');
- }).catch((error) => {
- console.log('Source sendRequest promise error:', error);
- return Promise.reject('There was an internal error sending the request.');
- }); }
- CheckSource(<Att_ID string here>, <Symbol_ID string here>).then((data)=>{
- console.log(data)
- });
- False //(this is the expected output from the conslole.log() in the async function)
- undefined //(this is the console.log() after I called the function)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement