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

still working on completing this workshop, submitting what I have don… #7

Open
wants to merge 1 commit into
base: main
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ app.get('/api', (req, res) => {

// get all pets from the database
app.get('/api/v1/pets', (req, res) => {
res.send(pets);
// send the pets array as a response

});

// get pet by owner with query string
Expand All @@ -36,10 +36,18 @@ app.get('/api/v1/pets/owner', (req, res) => {

});

// get pet by name
app.get('/api/v1/pets/:name', (req, res) => {
// get pet by name - Getting the pet by ID
app.get('/api/v1/pets/:name', (req, res, next) => {
// get the name from the request
const { id } = req.params;
if (!id.match(/[0-9]+/)) {
console.log('passing to next route');
next ();
}





// find the pet in the pets array
const pet = pets.find(pet => pet.name === name);
Expand Down
192 changes: 134 additions & 58 deletions package-lock.json

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

Loading