Skip to content

Commit

Permalink
basic api
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Jan 15, 2021
1 parent ff5f988 commit 124be08
Show file tree
Hide file tree
Showing 3 changed files with 868 additions and 0 deletions.
35 changes: 35 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var gis = require('g-i-s');

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || 45084;
const router = express.Router();
router.get('/', async function(req, res) {

//console.log(req)

// Access the provided 'search' query parameter

await gis(req.query.search + ' Official Photo', function(error, results) {
if (error) {
console.log(error);
}
else {
console.log(JSON.stringify(results, null, ' '));
console.log(results[0])
urlToDeliver = results[0].url
res.json({ url: urlToDeliver });
}
});

console.log(urlToSend)


});

app.use('/api', router);
app.listen(port);
console.log('Listening on port ' + port);
Loading

0 comments on commit 124be08

Please sign in to comment.