Using nested routing in ember


#1

Hi

I know this question already posted many times in the forum. I need some clarification from the experts. I have setup a project to read data from external API. Few methods in the API are

Here is the route setup

I was able to read the data from first URL. I am having problem reading data from second URL, I see this “www.payrollapi.dev//api/v1//clients/1” URL in the developer console, with 404 not found error. I know the URL is wrong, it is missing /employees at the end.

Is my route definition is correct, if not, please tell me what is the right route definition. Also the folder structure within the route folder and template folder.

Thanks


#2

Hi @prao.

Could you confirm which Ember.js version are you currently using? this.resource has been deprecated has it is no longer recommended.

From your description, you seem to be confusing your Ember application’s routes with the payrollapi server you are trying to get data from? The routes in router.js are the “screens”, or “pages” of your Ember application, and nested routes means that the templates are nested, meaning child templates visually appear inside the parent template. Requests to the API are independent of that.

Can you show us how you are making the requests to payrollapi.dev?


#3

Hi

Thanks for the reply. The ember version is 2.11.0, node version 6.6.0. The API call is made via REST adapter. The PayrollAPI is REST based API.

The route folder structure is Routes->Clients->Index.js, in this index.js I have this code, which fetches all clients.

To list the employees the route is in Routes->Clients->Client->Employees.js with this code.

Thanks