samedi 3 janvier 2015

Getting different url requests to API depending on how I've gotten to the page

I'm getting some curious behaviour that I can't figure out the reason for.


This is my router:



App.Router.map(function() {
this.resource('mapPieceSets', { path: '/map-pieces' }, function () {
this.resource('mapPieceSet', { path: '/:mapPieceSet_id' }, function () {
this.resource('mapPiece', { path: '/:mapPiece_id' });
});
});
});


I reload the app from the home page #/ then navigate down to the mapPiece route, I get these URLs requested:



  • [Domain]/api/mapPieceSets/

  • [Domain]/api/mapPieces/1/

  • [Domain]/api/mapPieces/2/


And it all works fine (mapPieceSets returns a list of mapPieceSet which have a list of mapPiece against them)


However, if I reload the whilst on a mapPiece routed page, then I get this URL:



  • [Domain]/api/mapPieceSets/

  • [Domain]/api/mapPieceSets/?mapPieceSet_id=1

  • [Domain]/api/mapPieces/?mapPiece_id=1


So switching from /:id= to ?id=, which isn't working on my end points (that's a side issue which I need to resolve), but just wondering why the URLs changed what they're requesting, and why we get a request to mapPieceSets/?mapPieceSet_id=1 when the whole of that object is returned within the response from mapPieceSets/


(If you need any other snippets of code from my app, let me know and I can put them in)





Aucun commentaire:

Enregistrer un commentaire