Closed artpylon closed 7 years ago
I added a console log inside the delete controller function, but it does not register in the server logs:
Would you mind posting your routes file? If that console.log is not firing, it seems like the issue could be there
Also, are you able to CURL it?
Routes:
.resources('files', { only: ['index', 'show', 'destroy', 'create', 'update'] })
Looks like your getting a 401 unauthorized
. Are files created with an owners field?
The 401 disappears after signing according to the console.log above
What about the CURL request? Any success there, or same issue?
In progress will report back
Getting permission denied but no 401 error when CURL requesting DELETE
What's the curl script look like?
ID=5953c9955de0ceb8156a6f96 TOKEN="X2ecjIjhOd/CLdb0tiYJ6F7UTwl5TzZI6m0k7j96KZY=--44sRR8buPoLagdTV91aj1Eb2QAajiqKSKWZb3nO+MAo=" assets/scripts/delete.sh
API="http://localhost:4741"
URL_PATH="/files"
curl "${API}${URL_PATH}/${ID}" \
--include \
--request DELETE \
--header "Authorization: Token token=$TOKEN"
echo
DELETE issue fixed, issue was routes. Now looks like .resources('files', { only: ['index', 'show', 'create', 'destroy', 'update'] })
Update/PATCH is still at404 error though
I still can't get the Update curl script or Update from the frontend. If DELETE is working, it's not the files schema at all and something is wrong with the update. I'm at a loss.
From the console logs in set-mongoose-model.js the File _id is not being correctly passed. I compared the examples schema to the files schema and noticed that at the bottom of the examples models file, module.exports = Example (Example is white) whereas the end of the files model file, module.exports = File (File is yellow).
DELETE should be going through the same mongoose-model code, yet still works.
Everything in this issue is about DELETE, not UPDATE. It's possible they both had the same thing wrong with them, but they also could be wildly different. Please post a new issue and close this one since the solution has been posted.
Opening a new issue for UPDATE.
Can this be closed now? The solution is above. Please open and close the issue for UPDATE as well, @MarcyNash !
delete works now, so closing this issue.
I am attempting to delete a file in my local db. I can see that the request includes the correct id of the file I'm trying to delete in the request URL, but it returns a 404.
My hunch is that this may be because the controller isn't looking for the file by the id...
events.js
api.js
Controller destroy function: