#UseContext & fetch

14 messages ยท Page 1 of 1 (latest)

outer jackalBOT
#

๐Ÿ”Ž This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

๐Ÿ•ต๏ธ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

โœ… You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

waxen rain
#

Add an api call to your counter increment/decrement buttons. When the user interacts with them they update your counter db table and if the operation succeeds you update your context state to reflect the new value stored in the database

#

Since you're updating an existing record I'd use the PUT method. POST is generally used when you're inserting new data into the database

#

Also, the PUT http method is idempotent meaning that two identical requests made at the same time modify the record only once.

#

I'm not sure I understood the question...

#

LGTM ๐Ÿ‘๐Ÿป

Now you just have to update the context state accordingly.

And if you need it you can also denounce the buttons to avoid multiple requests being made in a really short time span.

#

You should probably send it as { counter: number } and not { counter: { someObject } }

#

There's no body in the screenshot you sent... ๐Ÿ‘€

#

There's something wrong with your GET method implementation... The endpoint should be returning a counter object regardless of the response you get from the database...

#

If you link me the repository I can take a closer look tomorrow. Rn I better get some sleep lol

#

It could be... It could be a lot of things

#

It's ok, you don't have to know it to upload the code to a GitHub repo.
But anyways I'll take a look at the code you sent above tomorrow morning โœŒ๏ธ

waxen rain
#

Great, you figured it aout already all_the_things

outer jackalBOT
#
โœ… Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer

[Click here](#1150918984892424344 message)