I didn't see a post for the Toast package in the packages channel. So I thought I'd post my question here. @Jacob Kofoed
I've been struggling a bit on to get the toasts to work on the following use case:
I have a form that I want to submit with a button, to my database (so via an API POST). I see that with the Toast package I have to use the said button as a component. And in the component I set the messages for the toast. However, I want to show a success message on a successful submission and an error message when the submission didn't go through.
What is the best way to set this up?
I currently have this:
1. Click event in component.
2. Click on main page triggers the above.
3. And triggers an API call
4. On success/error...so this is where I get stuck.
I've been playing with attributes inside the component to get this working, but I have some doubts whether that is the best way to do it.
Apologies if this is basic question. My knowledge on how to make components communicate back and forth with the parent is limited. And I hope any answer/guidance with the above question will also help me understand it a bit better. For the record, I have watched the videos on YT regarding components, but they don't cover this use case (or I just fail to understand it in that way).
Thanks 🙏