Hi ,
I am new to nodejs and sencha development. I am trying to develop an
application using sencha. My application need to consume rest service,
which is implemented in nodejs using express module.
My sench application looks as follows.
Model: HelloWorldModel.js
-----------START-----------------------------
Ext.define('Hello.model.HelloWorldModel', {
extend: 'Ext.data.Model',
config: {
fields: [ 'id', 'content' ]
}
});
------------END------------------------------
View : HelloWorldView.js
-----------START-----------------------------
Ext.define('Hello.view.HelloWorldView', {
extend: 'Ext.Panel',
config: {
fullscreen: true,
tpl: '<p>The ID is {id}</p><p>The content is {content}</p>'
}
});
------------END------------------------------
Store : HelloWorldStore.js
-----------START-----------------------------
xt.define('Hello.store.HelloWorldStore', {
extend: 'Ext.data.Store',
config: {
model: 'Hello.model.HelloWorldModel',
proxy: {
type: 'rest',
url: 'http://localhost:8888/hello'
},
listeners: {
beforeload: function () {
var name = document.location.search.slice(1);
this.getProxy().setExtraParam('name', name);
}
}
}
});
------------END------------------------------
hello.js
-----------START-----------------------------
Ext.application({
name: 'Hello',
models: [ 'HelloWorldModel' ],
stores: [ 'HelloWorldStore' ],
views: [ 'HelloWorldView' ],
launch: function () {
var view = Ext.create('Hello.view.HelloWorldView', {});
Ext.create('Hello.store.HelloWorldStore', {
autoLoad: true,
listeners: {
load: function (self, records) {
view.setData(records[0].getData());
}
}
});
}
});
Ext.Loader.setConfig({ disableCaching: false });
------------END------------------------------
Application's index.html
-----------START-----------------------------
<!doctype html>
<html>
<head>
<title>Hello Sencha</title>
<script
src="//cdn.sencha.io/touch/sencha-touch-2.1.1/sencha-touch-all.js"></script>
<script src="hello.js"></script>
</head>
<body>
</body>
</html>
------------END------------------------------
Rest Service is implemented using node js express module nodejsExpress.js
-----------START-----------------------------
var express = require('express');
var app = express();
app.get('/hello', function(req, res) {
console.log("Received request for /hello");
res.send('{"id":85,"content":"Hello, World!"}')
})
app.listen(8888);
console.log("Listening on 8888");
------------END------------------------------
If I am calling http://localhost:8888/hello from sencha's application, I
could not see any console log message in the console where I ran
nodejsExpress.js , and no response to the sencha application
I also implemented the rest service using http module as follows
nodejsHttp.js`
-----------START-----------------------------
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8010, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8010/');
------------END------------------------------
If i invoke http framework implemented nodeJS service(using
http://localhost:8010 from the sencha application, I could see the response
received to sencha application along with the console log.
Can some body please help me what is cauaing the issue with express
framework nodejs implementation.
Thanks for your help in advance.
Thanks,
Ajay
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/eda9c0dc-8714-4ee0-a210-61dd7d44aa0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.