Ich bin neu in der MEAN-Stack und ich habe einige Probleme mit dem Routing ...mean.js eckig - Express-Routing
Ich habe ein Modul namens "Anwendungen". die APIs i auf der Server-Seite wollen, sind: get: http://localhost:3000/api/applications/(_appid) getByMakeathonId: http://localhost:3000/api/applications/makeathons/(_mkid)
Anwendungen Service
function ApplicationsService($resource) {
return $resource('api/applications/:path/:applicationId', {
path: '@path',
applicationId: '@id'
}, {
get: {
method: 'GET',
params: {
path: '',
applicationId: '@_id'
}
},
getByMakeathonId: {
method: 'GET',
params: {
path: 'makeathon',
applicationId: '@_id'
}
},
update: {
method: 'PUT'
}
});
Server Routing
app.route('/api/applications').post(applications.create);
app.route('/api/applications').all(applicationsPolicy.isAllowed)
.get(applications.list);
app.route('/api/applications/makeathon/:makeathonId').all(applicationsPolicy.isA llowed)
.get(applications.applicationByMakeathonID);
1), was ich Ich bekomme, wenn ich $ save anrufe und das Objekt und die Speicherung erfolgreich ist ul, es gibt einen Aufruf für .get, und die Anfrage URL ist: http://localhost:3000/api/applications//56f15736073083e00e86e170 (404 nicht gefunden) Das Problem hier ist natürlich das Extra '/' - Wie werde ich es loswerden.
2), wenn ich getByMakeathonId nennen, die Anforderungs-URL ist: http://localhost:3000/api/applications/makeathon?id=56e979f1c6687c082ef52656 400 (Bad Request)
ich mich so konfiguriere, dass ich die beiden Anfragen bekommen, was ich will?
10x!
Dies hilft gelöst mir ein anderes Problem – Sam