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

Pull request #2

Merged
merged 1 commit into from
Nov 17, 2022
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions routes/apiRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,55 @@
import express from 'express';
import fetch from 'node-fetch';

import foodService from './foodService.js';
import smithsonian from './smithsonian.js';

const router = express.Router();

router.get('/', (req, res) => {
res.send('Welcome to the UMD Dining API!');
res.send('Welcome to the Fresh4 Final Project Smithsonian API!');
});

// Generic API inclusion demonstration
// Replace this with the group member's actual route
// This leads to /api/member1
router.use('/foodService', foodService);
router.route('/smithsonian/owenK')
.get(async (req, res) => {
try {
const url = 'https://api.si.edu/openaccess/api/v1.0/stats?api_key=bDy3ONUljbeF9nhGIgWGL3G0EMCOcOgLgPGqXpDq';
const data = await fetch(url);
const json = await data.json();
console.log(json);

res.json({data: json});
} catch (error) {
console.log(error);
res.json({error: error});
}
})
.put((req, res) => {
try {
res.json({message: 'put Smitsonain endpoint'});
} catch (error) {
console.log(error);
res.json({error: 'Something went wrong on the server'});
}
})
.post((req, res) => {
try {
res.json({message: 'post Smithsonain endpoint'});
} catch (error) {
console.log(error);
res.json({error: 'Something went wrong on the server'});
}
})
.delete((req, res) => {
try {
res.json({message: 'delete Smithsonain endpoint'});
} catch (error) {
console.log(error);
res.json({error: 'Something went wrong on the server'});
}
});
router.use('/foodService', smithsonian);

export default router;
97 changes: 0 additions & 97 deletions routes/foodService.js

This file was deleted.