Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

For the need of a simple demonstrator, I've created a simple grid panel in ExtJS, and now i'm trying to fill it with data coming from MongoDB. I heard about Node.JS and stuff but there I just want to use the REST API of MongoDB to retrieve the data. Note : I'm new in ExtJS and REST request.

My problem is that when loading my page, there is no panel created and firebug tells me : ""NetworkError: 400 Bad Request - http://xxx.xxx.xx.xx:28017/mydb/device/find?_dc=1374225874880&page=1&start=0&limit=25""

If I copy and paste the URL http://xxx.xxx.xx.xx:28017/mydb/device/find?_dc=1374225874880&page=1&start=0&limit=25 I can see the data, so that means that the Mongo data are accessible through URL. Note that I dont' know where the "page=1&start=0&limit=25" param of the URL comes from, it wasn't implemented by me.

My code that is supposed to load the data is in my Store component of my MVC :

Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
autoLoad: true,
proxy: {
    type: 'rest',
url: 'http://xxx.xxx.xx.xx:28017/mydb/device/find',

    reader: {
        type: 'json',
        root: 'rows',
    idProperty: '_id'

    }
}
});

And this is what shows the Mongo URL :

{
"offset" : 0,
"rows": [
 { "_id" : "SheevaPlug", "manufacturer" : "GlobalScale" }
],

"total_rows" : 1 ,
"query" : {} ,
"millis" : 0
}

The mapping in the Model seems correct too :

Ext.define('AM.model.User', {
extend: 'Ext.data.Model',
fields: ['_id', 'manufacturer']
});

Thanks by advance if you can help me ! Cheers,

Vincent

share|improve this question
 
possible duplicate of JQuery AJAX GET request always returns error –  WiredPrairie Jul 19 at 10:58
1  
It's likely that you're trying to do a cross origin call, which isn't supported by the admin interface provided by MongoDb. It works when you paste it because then the browser is making a direct call. –  WiredPrairie Jul 19 at 11:00
 
Ok, so I guess it's better to use NodeJS anyway ! Thanks dude :) –  Secular Kid Jul 19 at 12:39
add comment

1 Answer

up vote 1 down vote accepted

Use Node.js to create MongoDB web services that you will call with Sencha.

share|improve this answer
 
Ok, I'll guess this is what I need to do :( –  Secular Kid Jul 19 at 12:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.