I'm currently discovering Google Datastore and it seems pretty useful.
However (I'm a JS newbie) I'm stuck with something pretty simple concerning Promise
and Async/await
, and I'm not able to find my answer (I tried...).
This get
works perfectly into my terminal (it's fairly simple):
datastore.get(datastore.key(['viewing', 'abc123']))
.then((slot) => {
console.log(slot[0])
})
But what I want is to wrap this query into a const
and return slot[0]
on-demand...
So I've tried:
const wrap = () => {
datastore.get(datastore.key(['viewing', 'abc123']))
.then((slot) => {
return slot[0]
})
}
Didn't work.
I've tried to add a return
before datastore.get
, to change a return
for a Promise.resolve
... but it's still the same : Promise pending
(best case).
I do not speak about using async/await
.
I can't return
my slot[0]
...
Any clue, thanks.