Mongo and Node.js timeshift=240

I"m following the Node.js and mongo tutorial here https://dhtmlx.com/blog/using-dhtmlxscheduler-with-node-js/
I just can’t seem to get the scheduler to load display the collection to the screen.

Here’s my error
dhtmlxscheduler.js:162 GET localhost:3000/data?timeshift=240 404 (Not Found)

[code]//Server side code
var http = require(‘http’);
var express = require(‘express’);
var logger = require(‘morgan’);
var path = require(‘path’);
var Promise = require(‘es6-promise’).Promise;
var cookieParser = require(‘cookie-parser’);
var bodyParser = require(‘body-parser’);

var db = require(‘mongoskin’).db(“mongodb://localhost:27017/cogen”, { w: 0});
db.bind(‘event’);

const app = express();

// app.use(express.bodyParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(’./public’)));

app.use(logger(‘dev’, {
skip: function (req, res) { return res.statusCode < 400 }
}));

/-----------------Event Handlers---------------------/

//Adds records to the database
app.get(’/init’, function(req, res){
scheduler.config.xml_date=’%Y-%m-%d %H:%i’;
console.log(‘anything?’)
db.createCollection(event, console.log(‘createCollection fired’));

db.event.insert({ 
    text:'Person 1', 
    start_date: new Date(2017,5,25, 0800),
    end_date:   new Date(2017,5,26, 1600),
    color: '#eee'
});
db.event.insert({ 
    text:'Person 2', 
    start_date: new Date(2017,5,5, 1600),
    end_date:   new Date(2017,5,6, 2359),
    color: "#BADA55"
});

/*... skipping similar code for other test events...*/

res.send("Test events were added to the database")

});

//Loads data from the database
app.get(’/getState’, function(req, res){
db.event.find().toArray(function(err, data){
//set id property for all records
for (var i = 0; i < data.length; i++)
data[i].id = data[i]._id;

    //output response
    res.send(getState);
});

});
/-----------------Event Handlers---------------------/

app.get(’/’, (req, res) => {
res.sendFile(__dirname + ‘index.html’);
});

const server = new http.Server(app);

const port = process.env.PORT || 3000;
server.listen(port, () => {
console.log(connected to port ${port});
});[/code]

[code]

Busch Cogen Calendar
<!-- <script type="text/javascript" src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script> -->
<script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js" integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30=" crossorigin="anonymous"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="/codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script><!-- DHX Scheduler -->
<script type="text/javascript" src="/javascript/script.js"></script>
Hello, interwebs
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
    <div class="dhx_cal_navline">
        <div class="dhx_cal_prev_button">&nbsp;</div>
        <div class="dhx_cal_next_button">&nbsp;</div>
        <div class="dhx_cal_today_button"></div>
        <div class="dhx_cal_date"></div>
        <div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
        <div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
        <div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
    </div>
    <div class="dhx_cal_header">
    </div>
    <div class="dhx_cal_data">
    </div>
</div>
<script type="text/javascript">
$('#init').ready(function(){
   		(function init() {
        scheduler.config.xml_date='%Y-%m-%d %H:%i';
        scheduler.init('scheduler_here', new Date(),"month");

        scheduler.templates.xml_date = function(value){ return new Date(value); };
        scheduler.load("/data", "json");

        var dp = new dataProcessor("/data");
        dp.init(scheduler);
        dp.setTransactionMode("POST", false);

        scheduler.parse(events, 'json');
    })();   
}); 

</script>
[/code]

Any help would be great thanks.

In my index file, line 51, I tried

scheduler.setLoadMode('/data', 'json');

Instead of

scheduler.load('/data', 'json');

Which gave me no error, which is good, but I have no error and no data so I used

console.log(scheduler.setLoadMode('/data'));

Which is displaying ‘undefined’ in my console.

I guess I’m kinda shooting in the dark here, so any help would be appreciated. Thanks :slight_smile:

Hi,

Here’s my error
dhtmlxscheduler.js:162 GET localhost:3000/data?timeshift=240 404 (Not Found)

I can see no route for this request in server-side code you provided.
Here is how such route looks like in the tutorial:
github.com/DHTMLX/node-schedule … app.js#L40

can you please send a complete code or create a public repository with your version to check the code?