Closed colias-palaeno closed 2 years ago
The problem with your code is that you don't await the response
Instead of
console.log(returnReqData());
Try
console.log(await returnReqData());
or
returnReqData().then(console.log)
Here is how you can simplify your code: https://runkit.com/gr2m/octokit-request-js-494/1.0.0
The problem with your code is that you don't await the response
Instead of
console.log(returnReqData());
Try
console.log(await returnReqData());
I tried both of your alternatives, and the console is simply outputting undefined
. Not sure why
oh sorry I just realized you'll also need to update
async function returnReqData(){
await req;
return req.data;
}
to
async function returnReqData(){
const { data } await req;
return data;
}
But this code is not very elegant, better look at how I implemented it at https://runkit.com/gr2m/octokit-request-js-494/1.0.0
Hi,
I'm having an issue with the
request()
method not returning any data from its promise - it simply returns[object Promise] { ... }
, with no other information.On the README page, it states that if the request promise is resolved, an object with 4 keys will be returned, and if the request promise is rejected, an object with 3 keys will be returned - as you can see, I'm getting neither of these.
Please find my code below: