Closed jpineda48 closed 11 months ago
Ive created actions but am unable to delete them.
action/delete api
export const removeAction = (user, goalId, actionId)=> { return axios({ url: `${apiUrl}/goals/${goalId}/${actionId}`, method: `DELETE`, headers: { Authorization: `Token token=${user.token}` } }) }
actionshow
import {useState} from 'react' import{Card, Button} from 'react-bootstrap' import { removeAction } from '../../api/action' import { removeActionFailure, removeActionSuccess } from '../shared/AutoDismissAlert/messages' const ActionShow = (props) => { const { action, msgAlert, triggerRefresh, user, goal} = props const deleteAction = () =>{ removeAction(user, goal._id, action._id) .then(() => msgAlert({ heading:'removed successfuly', message: removeActionSuccess, variant: 'success' }) ) .then(() => triggerRefresh()) .catch(() => msgAlert({ heading:'oh no!', message: removeActionFailure, variant: 'danger' }) ) } return ( <> <Card className='m-2'> <Card.Header> {props.action.action} <Card.Body> </Card.Body> </Card.Header> <Card.Footer> <small></small> <Button className='m-2' variant="danger" onClick={() => deleteAction()} > Delete Toy </Button> </Card.Footer> </Card> </> ) } export default ActionShow
seeing my error message for deleteActionFailure
I think it is in my API because it is also not working in postman.
Paste a link to your repository here
https://github.com/jpineda48/myGoalsApp
Share your route you're trying to hit, the place those routes are registered in server.js and your Postman error.
server.js
literally mentioned that, and it was a route issue! I had "goals" where "actions" should be.
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
What's the problem you're trying to solve?
Ive created actions but am unable to delete them.
Post any code you think might be relevant (one fenced block per file)
action/delete api
actionshow
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
seeing my error message for deleteActionFailure
What is your best guess as to the source of the problem?
I think it is in my API because it is also not working in postman.
What things have you already tried to solve the problem?
Paste a link to your repository here
https://github.com/jpineda48/myGoalsApp