I am very new to NodeJs. I am using express module in NodeJS and trying to load html files through sendFile command. While doing it my first sendfile command works well, however it doesnt work well for second sendFile command. Can anyone please let me know whats going wrong here?
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res){
res.sendFile(path.join(__dirname, 'public/index.html'));
});
app.get('/unpack', function(req, res){
res.sendFile(path.join(__dirname, 'public/main.html'));
});
In the above code the below line works well
res.sendFile(path.join(__dirname, 'public/index.html'));
Problem lies with
res.sendFile(path.join(__dirname, 'public/main.html'));
Thanks @warl0ck and @robertklep for your response. As @robertklep mentioned in the comments section my problem was that I was using AJAX to call /unpack hence I was getting the response as html code. This helps me to understand the problem and I will change AJAX to something else.
Thanks @warl0ck and @robertklep again!!!
-kt