Denzel NIi Armah Ashitey
@DennyIsNaiveAll comments
- @ArbAnk007Submitted 12 months ago@DennyIsNaivePosted 12 months ago
It seems the quotes don't update at all, this is because data is being cached. To resolve this, we have to tell the browser not to cache any data to memory. You can explicitly do this by adding a little code to the fetch method like so :
const response = await fetch(url{cache: 'no-cache'});
I hope this helps XD
Marked as helpful1 - @rainSaxSubmitted 12 months ago
Any Feedback Appreciated
@DennyIsNaivePosted 12 months agoHi, it seems you can't change the quote when you click on the dice button. This is because the data is being cached and when you click on the dice, it returns the cached data again. To fix this, make sure no data is cached at all buy setting cache to no-cache like so :
fetch(apiUrl, {cache: 'no-cache',})
. I hope this helps XD0 - @ClaudioAmarenoSubmitted 12 months ago
Hello, it's my first project with API. Could you tell me why I can't use 2 times then(data =>) in one Fetch? Thank you for any feedback!
@DennyIsNaivePosted 12 months agoHey, there are a few problems with the code you wrote. First off, the quote is cached for a period of time before being removed from the cache memory, this makes it impossible to generate new quotes whenever you click on the dice. It only works once, is cached and then you have to wait for several minutes. To solve this problem, make sure no data from the api is cached or stored by explicitly defining it like so :
fetch(apiUrl, {cache: 'no-cache',})
.The next problem is that, you are fetching the same API twice. You already fetched data from the API when you first used fetch(URL) so there is no need for you to fetch the data again. You can still use the API call to define the advice number as well. Hope this helps, happy coding! XD
Marked as helpful1 - @SvitlanaSuslenkovaSubmitted 12 months ago
Will be glad to receive any advice on my js code.
- Max length for inputs was a problem and I'm not sure if I did it right.
- To add spaces into input card number was difficult and I don't like the way I did it. I saw there is a mask fo this, but it didn't work in any way possible.
- Used Luhns validation: Valid numbers examples: 4444 4444 4444 4444 4 4444 4444 4444 4448 5555 5555 5555 5557
@DennyIsNaivePosted 12 months agoI don't know if you forgot or you didn't see it but there is a completion page after clicking on the confirm button. Does not work or has not been included.
0 - @daniel-ribasSubmitted 12 months ago
Trust me guys, i had to change the card height cause sometimes the API brings big advices.
@DennyIsNaivePosted 12 months agoThe API gives each advice a number so you can reference that object inside the advice heading a
adviceNumber.textContent = #ADVICE ${data.slip.id};
so the API does the changes automatically instead of using js to manually change the numbers.There is also a small problem in your code. The quotes in your website do not change even after waiting for 5 minutes. This is because the quotes are stored temporarily before being removed from cache memory. In the docs, it says 2 seconds but ideally it is more than that. I'd advice you set cache: 'no-cache' manually when using the API so data isn't cached at all. Your UI looks splendid. All that is left is the problem with caching the quotes. I hope this helps XD
Marked as helpful0 - @Kyureus1Submitted 12 months ago
when you inmediately click on the button after the advice shows up on the screen, it flashes and shows the same advice, it takes like a 2 or 3 seconds delay to show a new one, if you click on the button during these time, it will not change. I couldn't find out how to help that, i want the request to be faster and smoother. i will be checking some other solutions to see if i can do it.
@DennyIsNaivePosted 12 months agoThis problem is not your fault. Rather data is being stored (cached for a period of 2 to 3 seconds). This problem is inherent from the API and is even specified in the documentation. To resolve this, you might have to use another API or you can set the cached state to no-cache explicitly so no data is cached at all.
Marked as helpful1