warengonzaga/buymeacoffee.js

no data return on request

warengonzaga opened this issue ยท 17 comments

Someone reported this issue to me from the BMC Discord community.
After testing, it is a valid bug and needs to fix. ๐Ÿ˜ข

The issue could be on how the client communicates with the API.

I know this is like two weeks after the issue was reported but it might not be a bug with the client, the token could simply have expired. The BMC API returns a JWT token, which contains an expiration timestamp. If that timestamp elapses then the token is no longer valid. I'm curious to learn how this issue was reported and tested. ๐Ÿ‘

Can't find the exact issue why there is no response when you console log the response. If anyone has an idea why we can discuss it here. Also, this is part of hacktoberfest.

Update, when you test it on postman it returns data. I guess the issue is on the wrapper itself (maybe). Still need to find the root cause so we can fix it as quickly as possible.

Hi! You test for this package or directly on BMC API ? @warengonzaga

Hi! You test for this package or directly on BMC API ? @warengonzaga

I test directly on BMC API I believe the issue is on how we fetch the data using this wrapper.

So weird. I tested with Hoppscotch, not working and show me the login page.
image

Directly with CURL, he work !
image

Blur is private content, like emails, transactions, price...

@thomasbnt that's weird also on my end. You can directly call the API. I might rewrite the whole API wrapper. How about let's test the old version of this package? To be specific the alpha version. If it works meaning the latest version sucks.

Are you able to fix it @thomasbnt?

So weird. I tested with Hoppscotch, not working and show me the login page.

That's what happens when the bearer token isn't present and/or invalid, it happens with postman as well.

Screenshots

Screen Shot 2021-10-15 at 8 41 33 AM
Screen Shot 2021-10-15 at 8 41 55 AM

I might rewrite the whole API wrapper.

Could it be how you call the methods on the wrapper? In your tests, you are using async, await. But in the documentation, you are calling the methods directly and not handling the promise.

const coffee = new BMC(access.token);
coffee.Supporters(data => console.log(data));

This will result in a pending promise that's not handled since it's missing the then call.

coffee.Supporters().then(data => console.log(data));

So weird. I tested with Hoppscotch, not working and show me the login page.

That's what happens when the bearer token isn't present and/or invalid, it happens with postman as well.

Screenshots
Screen Shot 2021-10-15 at 8 41 33 AM Screen Shot 2021-10-15 at 8 41 55 AM

I might rewrite the whole API wrapper.

Could it be how you call the methods on the wrapper? In your tests, you are using async, await. But in the documentation, you are calling the methods directly and not handling the promise.

const coffee = new BMC(access.token);
coffee.Supporters(data => console.log(data));

This will result in a pending promise that's not handled since it's missing the then call.

coffee.Supporters().then(data => console.log(data));

Thank you for trying to fix the issue, @JohnDoePBabu is the one who updates the API wrapper and I might re-code it. I'll consider your input @thinkverse and check it out. If you can fix the methods feel free to submit a PR.

Are you able to fix it @thomasbnt?

Hello @warengonzaga, I don't know and I haven't tried with BMC.js yet

alright @thomasbnt I'll try to fix it based on the study made by @thinkverse.

I'll work on this by weekends so we can add this to the v2 update of BMC.JS

So weird. I tested with Hoppscotch, not working and show me the login page.

That's what happens when the bearer token isn't present and/or invalid, it happens with postman as well.

Screenshots

I might rewrite the whole API wrapper.

Could it be how you call the methods on the wrapper? In your tests, you are using async, await. But in the documentation, you are calling the methods directly and not handling the promise.

const coffee = new BMC(access.token);
coffee.Supporters(data => console.log(data));

This will result in a pending promise that's not handled since it's missing the then call.

coffee.Supporters().then(data => console.log(data));

You are correct @thinkverse! I just tested it out and works fine.

Everyone here, I just found out the solution to the problem why it is not working. I'll PR the update for the fix. Big thanks to @thinkverse for explaining.

Closing this issue for now, since it is now clear. Our example is confusing I'll update the documentation.

We updated the example in the docs... kindly check our official docs page here: https://docs.warengonzaga.com/buymeacoffeejs