-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (39 loc) · 1.21 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict'
const CONFIG = require("./client/config/config.js");
console.log(CONFIG);
const express = require('express')
const app = express()
const amazon = require('amazon-product-api');
const {json} = require('body-parser');
app.use(json());
var client = amazon.createClient({
awsId: CONFIG.key,
awsSecret: CONFIG.secret,
awsTag: "sorrelbrigman-20"
});
app.post('/api/amazon', (req, res, err) => {
console.log("amazon!!!");
console.log("req,body", req.body);
console.log("req.body.params.Keywords", req.body.params.Keywords);
client.itemSearch({
// Keywords :"piñon coffee",
// responseGroup : "ItemAttributes,Offers,Images",
// searchIndex : "Grocery"
// responseGroup: 'ItemAttributes,Offers,Images'
Keywords : req.body.params.Keywords,
searchIndex: req.body.params.searchIndex,
responseGroup: 'ItemAttributes,Offers,Images'
}).then(function(results){
console.log("results", results)
res.send(results);
}).catch(function(err){
console.log("error", err.Message)
res.send(err);
});
})
const PORT = process.env.PORT || 3000
app.use(express.static('client'))
//listen
app.listen(PORT, () => {
console.log(`Hey, I'm listening on port ${PORT}`);
})