javascript - Get search results from Last.fm API using Node and Angular -


i trying use node-lastfmapi track.search method. able results unsure on how display them on front end using angular. using mongodb database , have created schema particular search result user wants select , wants save. before that,the user needs see search results. how can display these results queried 3rd party api express.js ?

this code have written far

 app.post('/api/shows', function(req, res, next) {     var trackname = req.body.trackname;  //search bar gets trackname user enters lfm.track.search({     'track' : trackname }, function (err, track) {        if(!track.album.title) {               return res.send(404, { message: req.body.trackname + ' not found.' });  }     }); 

i create simple code snippet searching in lastfmapi , send results json in express.

var lastfmapi = require('lastfmapi');  var express = require('express'); var app = express(); var port = process.env.port || 8080;  var bodyparser = require('body-parser')  var lfm = new lastfmapi({    //you keys here });  app.use(bodyparser.urlencoded({ extended: false }));  app.post('/api/shows', function(req, res, next) {     var trackname = req.body.trackname;     console.log('get req');      lfm.track.search({ 'track' : trackname }, function (err, track) {          res.json(track);     }); });   console.log('start listen! on port: ' + port); app.listen(port); 

if want save results lfm api response in mongodb create own mongoose model , use them in snippet.

also did know why add angularjs in question. anyways cant use $resource https://docs.angularjs.org/api/ngresource/service/$resource data resful api in frontend app.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -