# Best Practise for storing api routes?

**URL:** <https://discourse.aurelia.io/t/best-practise-for-storing-api-routes/1474>\
**Category:** Help Requests\
**Created:** [July 30, 2018, 3:53pm UTC](https://discourse.aurelia.io/t/best-practise-for-storing-api-routes/1474 "2018-07-30T15:53:16Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![jsobell](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jsobell/32/87_2.png) [@jsobell](https://discourse.aurelia.io/u/jsobell)\
**Post date:** [August 7, 2018, 2:55pm UTC](https://discourse.aurelia.io/t/best-practise-for-storing-api-routes/1474/21 "2018-08-07T14:55:00Z")

</div>

Yes, it’s generating DTOs, so you can do whatever you like with them. It’s best to leave DTO’s as data-only, otherwise you can’t ‘cast’ the result of a fetch to a DTO without instantiating each as an instance of that object type and injecting all the properties.  
As a vanilla DTO you can cast the receive JSON data straight to the DTO type, as shown in the example above. The `Project` is a DTO that was generated as an interface, and the line `projects => this.accountProjects = projects` only works because the DTO is pure data without any metadata.  
e.g.:

```auto
export interface Project {
    Apikey?: string | undefined;
    CustomerAccountId?: string | undefined;
    Description?: string | undefined;
    Name?: string | undefined;
    ProjectId?: string | undefined;
    ScriptVersion?: number | undefined;
    TagsDefinition?: string | undefined;
}

```

I won’t post the whole of the `promise` function, but the key aspect is this at the end:

```auto
projects(projectId: string, customerAccountId: string | undefined): Promise<Project[]> {
: 
        return this.http.fetch(url_, options_).then((_response: Response) => {
            return <Project[]>JSON.parse(_responseText, this.jsonParseReviver);
        });
}

```

Have fun 😃

[Previous page](https://discourse.aurelia.io/t/best-practise-for-storing-api-routes/1474.md?page=1)
