# Category: http

I’m new to node and angular script. I’m having a function readDetails within my service which gives a GET request. this.readDetails = function() { return $http({ method: ‘GET’, url: ‘/getDetails’ }).then(function(data) { return data; }); } Given below is my server side code. app.get(‘/getDetails’, function(request, response) { fs.readFile(‘details.json’, ‘utf8′, function(err, data) { if (err) throw err; var obj = JSON.parse(data); response.send(obj); response.end(); }) }) I don’t get the response from the server. I do not […] ## AngularJS – ‘Data must be a valid JSON object’ error when loading via$http get

I’m trying to extract data for a list of employees from a json file using a $http.get request in my angular app, but the console is showing the following error: Error: [$http:baddata] Data must be a valid JSON object. Received: “{…… Not sure what is wrong, but I’ve not worked with http requests to get json files much before, and I think my json looks fine. – JSON: { ’employees’: [ { id: ‘21101994’, icon: […]

## Failed to connect socket using https in nodejs

While developing a chat application using nodejs,angular i am trying to connect with socket with the help of namespace using http , it was perfectly working.While i am running the same application with https, it was not connecting to socket code. server require(‘./libs/socketioCode.js’).sockets(https); var options = { key: fs.readFileSync(‘privkey.pem’), cert: fs.readFileSync(‘cert.pem’) }; var server = http.createServer(app).listen(3000); var server1 = https.createServer(options, app).listen(3443); var io = require(‘socket.io’).listen(server1); socket module.exports.sockets = function(https){ io = socketio.listen(https); I tried this […]