diff --git a/README.md b/README.md index a1a023a..79e3d28 100644 --- a/README.md +++ b/README.md @@ -44,15 +44,15 @@ Returns an array with `{number}` quotes e.g. `GET /quotes/3`. } ] -### `GET /quote/{id}` +### `GET /quotes/id/{id}` Get the corresponding quote from its `id` in this format: -> [https://the-dune-api.herokuapp.com/quote/40](https://the-dune-api.herokuapp.com/quote/40) +> [https://the-dune-api.herokuapp.com/quotes/id/66](https://the-dune-api.herokuapp.com/quotes/id/66) [ { - id: "96", + id: "66", "quote": "A man's flesh is his own; the water belongs to the tribe.", } ] @@ -103,11 +103,11 @@ Returns an array with `{number}` books e.g. `GET /books/3`. } ] -### `GET /book/{id}` +### `GET /books/id/{id}` Get the corresponding book from its `id` in this format: -> [https://the-dune-api.herokuapp.com/book/1](https://the-dune-api.herokuapp.com/book/1) +> [https://the-dune-api.herokuapp.com/books/id/1](https://the-dune-api.herokuapp.com/books/id/1) [ { diff --git a/loaders/getArticle.js b/loaders/getArticle.js index 1da949c..068826c 100644 --- a/loaders/getArticle.js +++ b/loaders/getArticle.js @@ -83,8 +83,8 @@ function getRandom(type, number) { function getArticle(type, id) { if (type == 'quotes') { - if (id < 0) { - return quotes[1] + if (id <= 0) { + return quotes[0] } else if (id > quotes.length) { return quotes[quotes.length - 1] @@ -94,8 +94,8 @@ function getArticle(type, id) { } } else if (type == 'books') { - if (id < 0) { - return books[1] + if (id <= 0) { + return books[0] } else if (id > books.length) { return books[books.length - 1] @@ -105,8 +105,8 @@ function getArticle(type, id) { } } else if (type == 'movies') { - if (id < 0) { - return movies[1] + if (id <= 0) { + return movies[0] } else if (id > movies.length) { return movies[movies.length - 1] @@ -116,8 +116,8 @@ function getArticle(type, id) { } } else if (type == 'series') { - if (id < 0) { - return series[1] + if (id <= 0) { + return series[0] } else if (id > series.length) { return series[series.length - 1] @@ -127,8 +127,8 @@ function getArticle(type, id) { } } else if (type == 'stories') { - if (id < 0) { - return shortStories[1] + if (id <= 0) { + return shortStories[0] } else if (id > stories.length) { return shortStories[shortStories.length - 1] @@ -138,8 +138,8 @@ function getArticle(type, id) { } } else if (type == 'comics') { - if (id < 0) { - return comics[1] + if (id <= 0) { + return comics[0] } else if (id > comics.length) { return comics[comics.length - 1] diff --git a/server.js b/server.js index 950defb..ea2b516 100644 --- a/server.js +++ b/server.js @@ -23,7 +23,7 @@ app.get('/:type/id/:id?', function (req, res) { }); app.get('/', (req, res) => { - res.status(200).status(200).send("Welcome to the DUNE API") + res.status(200).send("Welcome to the DUNE API") }); app.listen(PORT, function () {