Closed yuvanesh10 closed 6 years ago
Already answered here: https://github.com/arangodb/arangodb/issues/4112#issuecomment-353068528
@Simran-B If you dont mind me asking..,how can I await the result ? Even I used .then() but the result was same.
I had something like this
.then(function(response) { console.log(
Retrieved documents., response._result); return res.status(200).json(response._result);
@Simran-B @lodestone
I have tried in this way too
db.query(aqlQuery`
LET startVertex = (FOR doc IN spec
FILTER doc.serial_no == '"123456abcde"'
LIMIT 2
RETURN doc
)[0]
FOR v IN 1 ANY startVertex belongs_to
RETURN v.ip`,
{
bindVar1: 'value',
bindVar2: 'value',
}
).then(function(res) {
console.log("" + res._result);
});
I tried to feed in the soap msg
'<status xsi:type="xsd:string">' + (res._result) + '</status>' +
and I am getting the ERROR:
ReferenceError: res is not defined
What am I doing wrong here ? I have been stuck at this point for a week .,Can someone help me figure it out ?
@yuvanesh10 It sounds like your problem is not related to arangojs but to a misunderstanding about how JavaScript promises work. I suggest you read this introduction first:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
I'm not sure where your SOAP code is in relation to the code you posted, but the error you're seeing is because the res
argument is likely not in scope. Note that the function you pass to then
is still a function and the same usual rules for scope apply:
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Functions
I'm closing this as it's not an arangojs question but a general JS question.
If you would like a more extensive introduction to JavaScript language features I would suggest checking out the (free) book series You Don't Know JS by Kyle Simpson, especially the book Async & Performance which covers async/await and promises:
I have been trying to get a query result from Arangodb in to my front end service(Angular 4) using soap message. I am able to get a result of the query but printed out in console.log. But how can I get it under this function(myService). In other words, How can I feed my query result into a function rather than printing out the result in console. So that I can use this function to get the output of the query?
`server.js
I would like to feed the function into soap msg and receive it Angular 4
But the output is either empty braces If I am using JSON.stringify or else it is [object Promise]. What am I doing wrong here ?