currently using Loopback for my apiserver. I created a custom method so I can delete a single test at a time. However, when I use POSTMAN to try it, I get a 404 with the messageShared class \"Account\" has no method handling POST /deleteSingleHearingTest?access_token=Xif2NXXXXXXXXXkM2IF5AA1AWoDbckeddAuEG9ZuiZinvug6eDES28OayA1AIR4", My account.js file looks like thisAccount.deleteSingleHearingTest = function (req, callback) { // console.log('accounts.js: deleteSingleHearingTest: are we being reached????', req) Account.findById(req.accessToken.userId) .then(account => { if (!account) { throw new Error('Cannot find user'); } console.log('account.js: deleteSingleHearingTest: req.body.hearingTestId N: ', req.body.hearingTestId); return app.models.HearingTest.updateAll({ accountId: account.id, id: req.body.hearingTestId }, { isDeleted: new Date() }); }) .then(() => { callback(null); }) .catch(error => { callback(error); }); } Account.remoteMethod( 'deleteSingleHearingTest', { http: { path: '/deleteSingleHearingTest', verb: 'post' }, accepts: [ { arg: 'req', type: 'object', description: 'removes a single hearing test', http: { source: 'req' } } ], description: 'this is the end point for a single delete', returns: {} } ); I've updated my account.json with the following:{ "accessType": "EXECUTE", "principalType": "ROLE", "principalId": "$authenticated", "permission": "ALLOW", "property": "deleteSingleHearingTest" } What could be causing me to get a 404? I've looked up some possible answers and one post mentioned that a 404 is usually the result of wrong URLs or wrong Http methods. I'm quite certain that the URL is correct because I've tested other end points and they work fine.
Submitted November 05, 2018 at 06:05AM by jjssjj71
No comments:
Post a Comment