I have created the database and written the mp3 file in the db.Now I have created a server and used the router using express.But I am unable to see the response.It is displayed below.
My code is as follows:
server.js
var express = require('express');
var app = express();
var mongoose = require('mongoose');
var morgan = require('morgan');
var bodyParser = require('body-Parser');
var methodOverride = require('method-override');
var cors = require('cors');
mongoose.connect('mongodb://localhost/aHolyBoly');
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({ 'extended': 'true' }));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));
app.use(methodOverride());
app.use(cors());
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
//res.header('Access-Control-Allow-Methods', 'DELETE, PUT');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var Songs = mongoose.model('Songs', {
title: String
});
app.get('/api/songs', function (req, res) {
console.log("fetching songs...");
Songs.find(function (err, songs) {
if (err)
res.send(err)
res.json(songs);
//console.log('Songs',+JSON.stringify(Songs));
});
});
app.listen(8080);
console.log("App listening on port 8080");
How can I see the response in the console.i.e my songs.mp3 file?
via Aditya Jain

No comments:
Post a Comment