Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main page and individual product pages #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const express = require('express')
const app = express()
const exphbs = require('express-handlebars');
const axios = require("axios");
const fetch = require("node-fetch");

app.engine('handlebars', exphbs());
app.set('view engine', 'handlebars');

app.use(express.static('public'))
app.use(express.static(__dirname + '/'));

const url = 'https://next.json-generator.com/api/json/get/EkzBIUWNL'
const data = fetch(url).then(response => response.json())
.then( (result) => {
return result
})
.catch(error => console.log('error:', error));

app.get('/', (req, res) => {
data.then(result => {
// let productArray = Object.keys(result).map(product => result[product])
console.log("FIRST RESULT!", result[Object.keys(result)[0]])
res.render('grid', {data: result});
})
});

app.get('/product/:id', (req, res) => {
const productId = req.params.id
data.then(result => {
const data = Object.keys(result).find(i => {
return result[i].guid === productId
})
console.log(result[data])
res.render('product', { data: result[data] })
})
});


app.listen(process.env.port || 3000);
1 change: 1 addition & 0 deletions node_modules/.bin/handlebars

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/is-ci

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/nodemon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/nodetouch

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/nopt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/rc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/uglifyjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions node_modules/abbrev/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions node_modules/abbrev/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions node_modules/abbrev/abbrev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions node_modules/abbrev/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading