Skip to content

Commit e228c95

Browse files
committed
Change order of the routes to match with code in the example repo
1 parent df09191 commit e228c95

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/content/4/en/part4b.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,15 @@ The library handles everything under the hood. If an exception occurs in an <i>a
861861
The other routes become:
862862

863863
```js
864+
notesRouter.get('/:id', async (request, response) => {
865+
const note = await Note.findById(request.params.id)
866+
if (note) {
867+
response.json(note)
868+
} else {
869+
response.status(404).end()
870+
}
871+
})
872+
864873
notesRouter.post('/', async (request, response) => {
865874
const body = request.body
866875

@@ -872,15 +881,6 @@ notesRouter.post('/', async (request, response) => {
872881
const savedNote = await note.save()
873882
response.status(201).json(savedNote)
874883
})
875-
876-
notesRouter.get('/:id', async (request, response) => {
877-
const note = await Note.findById(request.params.id)
878-
if (note) {
879-
response.json(note)
880-
} else {
881-
response.status(404).end()
882-
}
883-
})
884884
```
885885

886886
### Optimizing the beforeEach function

src/content/4/fi/osa4b.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,15 @@ Kirjaston ansiosta kutsua _next(exception)_ ei siis enää tarvita. Kirjasto hoi
852852
Muut routet yksinkertaistuvat seuraavasti:
853853

854854
```js
855+
notesRouter.get('/:id', async (request, response) => {
856+
const note = await Note.findById(request.params.id)
857+
if (note) {
858+
response.json(note)
859+
} else {
860+
response.status(404).end()
861+
}
862+
})
863+
855864
notesRouter.post('/', async (request, response) => {
856865
const body = request.body
857866

@@ -863,15 +872,6 @@ notesRouter.post('/', async (request, response) => {
863872
const savedNote = await note.save()
864873
response.status(201).json(savedNote)
865874
})
866-
867-
notesRouter.get('/:id', async (request, response) => {
868-
const note = await Note.findById(request.params.id)
869-
if (note) {
870-
response.json(note)
871-
} else {
872-
response.status(404).end()
873-
}
874-
})
875875
```
876876

877877
### Testin beforeEach-metodin optimointi

0 commit comments

Comments
 (0)