@melwynt
Posted
Hi there!
Good job on the design.
For the quotes, you might want to use those symbols instead to respect the design: Reversed Double Prime Quotation Mark
The dice button is not working. I also used React for this project. Please feel free to check my solution here.
I think you are facing the same issue that I had.
Fetch
(or Axios
) is caching the data.
Because of this it will always return the same value.
To overcome this, the URL needs to be always different.
This can be done by inserting a timestamp in the url.
Here's an example with Axios
:
const getData = async () => {
const url = 'https://api.adviceslip.com/advice';
const data = await axios.get(`${url}?timestamp=${new Date().getTime()}`);
setAdvice(data.data.slip);
};
All the best!
Marked as helpful
@Adhi-S12
Posted
@melwynt Hello, Thanks for the input, I was planning to add Reversed Double Prime Quotation Mark but forgot to add it at the end. I just checked now, the dice button is working. In the Api docs it is mentioned that Advice response is cached for 2 seconds. Any repeat-request within 2 seconds will return the same piece of advice. Thanks for the timestamp tip, I'll try it in the project.