Saturday 14 March 2020

Ember data read from json file

Search for 'json file' from Ember tutorial page



It talks about putting json file public >> api >> workorder.json
Main route file, workorder.js file will read the json file as below.


export default class WorkordersRoute extends Route {

async model() {
let response = await fetch('/api/workorders.json');
let parsed = await response.json();
console.log("parsed", parsed);
return parsed;

}
}

You can add css into public >> assets >> scr.css
and include it from index.html file.

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/sydney-camera-repair.css">


API working, route is working. good



{{#each @model as |wo|}}
<span class="mybold">{{wo.id}}</span>
<WorkOrderListing @workorder={{wo}} />
{{/each}}



No comments:

Post a Comment