PrimeAcademy / biscayne-syllabus

1 stars 4 forks source link

Getting an infinite Loop on my Delete Route #11

Closed AsiaOsman06 closed 1 month ago

AsiaOsman06 commented 1 month ago
Screenshot 2024-05-29 at 10 07 25 AM

Screenshot 2024-05-29 at 10 05 02 AM

Description

Your Real Name

Asia Osman

What do you want to happen? i just need it when i click delete button to delete it forever. What is actually happening?

when i delete an exercise is not delete from backend or my database and it giving an infinite delete until i stop the server it wont stop.

Screenshots / Code Snippets

What did you try? Who did you ask?

i use my previous class assignments making sure my delete dispatch type is same on both saga and reducer. other than i don't see anything wrong with my code after i ask suzzy for help and she help but she was busy doing her solo project

What branch is your code on? Did you git push?

my main branch FitnessFollower_App yes

When was the last time you took a break?

just my day get started

matthew-black commented 1 month ago

Let's get this fixed!

First off, here are a few things to verify that'll help you isolate the problem:

  1. Verify that your DELETE route works.
    • It looks like it won't, as the actual route inside workout.router.js doesn't have a route parameter defined. (Compare Line 63 to Line 23.)
  2. Make sure that the dispatch sent by your deleteWorkoutPlan function contains the correct id value as its payload.
  3. Confirm that Line 36 within your deleteExercise Saga function is logging out the correct action.payload value.

Each one of these ☝️ things is important context that should ideally be included in an issue report. You did a great job communicating what isn't working, but collaboratively solving problems also requires communicating very clearly about which specific bits are working. 🙂


All of that said, I took a quick peek at your code, and it looks like you're doing the right thing! But, it also looks like you're doing an extra/unnecessary thing that might be causing the infinite loop:

Screenshot 2024-05-29 at 10 09 12 AM

Within your deleteExercise Saga function, once this line of code is working:

yield axios.delete(`/api/workout/workoutPlan/${action.payload}`, config);

You'd just need to call your fetchWorkoutPlans Saga function to "bring your workoutPlan reducer back in sync with the workout_plan table." Remember that we can do that with yield put():

yield put({type: 'FETCH_WORKOUT_PLANS'})

Let me know if this helps the issue!