-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
37 lines (30 loc) · 937 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// test.js
var express = require("express");
// var db = require("./models/index.js");
var request = require("request");
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.urlencoded());
app.set('view engine', 'ejs');
// app.get('/',function(req, res){
// var url = "http://api.jambase.com/events?artistId=2698&zipCode=95128&radius=50&startDate=2014-08-04&page=0&api_key=dwa8856tnfz4v2d55nye56xg"
// console.log(url)
// request(url, function(error, response, body){
// if(!error){
// var body = JSON.parse(body);
// console.log(url)
// res.render('results')
// }
// })
// })
app.get('/search', function(req, res){
var query = req.query.searchTerm;
var url = "http://www.omdbapi.com/?s=" + query;
console.log(url)
request(url, function(error, response, body){
if(!error){
var body = JSON.parse(body);
res.render('results', {movieList: body.Search});
}
});
});