I am using Ember-CLI with Ember 2.2.0 and Ember Data 2.0. This problem was happening before I upgraded my ember-cli to the latest ember.
I have a fairly simple Ember app. There is a 'users' file on my server hard coded for testing with some json of some sample user accounts. https://example.com/users
{"users": [{"id":1,"firstName":"Peter","lastName":"blah","email":"[email protected]","password":"blah","phone":"212-555-1212","isActive":"true"},{"id":2,"firstName":"George","lastName":"blah","email":"[email protected]","password":"blah","phone":"310-555-1212","isActive":"true"}]}
On my development machine I have a generated Ember-cli app with the following modifications:
router.js
...
Router.map(function() {
this.route('users', function() {});
});
...
users.hbs
<h1>Users Route</h1>
<h1>Users Index</h1>
<Table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
{{#each users as |user|}}
<tr>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td>{{user.email}}</td>
<td>{{user.phone}}</td>
</tr>
{{/each}}
</table>
{{outlet}}
in my routes folder:
user.js
export default Ember.Route.extend({
model: function() {
return this.store.findAll('user');
}
});
Ember throws the following parsing error when it tries to access the users model:
Error while processing route: users.index Unexpected token < SyntaxError: Unexpected token <
I can clearly see in the ember inspector that it is trying to parse my index.html page!! WTH??
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>UserMan</title>
....
Even if I go to the ember inspector, and go to the users route, then try and access the model using the store:
$E.store.findAll('user')
The parsing error happens and its clearly trying to parse the index.html page again.
Any ideas where ember is going wrong? Or what I am doing wrong?
users? Do you have an adapter (JSONAPIAdapter, ou RESTAdapter?) - Pedro Riousersendpoint? what does the request look like, what does the response look like? Also, you mention that your route isusersbut your route file (in your code saysuser.js(singular) while the other files areusers.*- Pedro Rio