Skip to content

Commit d571b8c

Browse files
authored
Update osa8c.md
1 parent 10d79aa commit d571b8c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content/8/fi/osa8c.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,15 @@ Mutaation toteuttava resolveri:
456456

457457
```js
458458
addAsFriend: async (root, args, { currentUser }) => {
459-
const nonFriendAlready = (person) =>
460-
!currentUser.friends.map(f => f._id.toString()).includes(person._id.toString())
461-
462459
if (!currentUser) {
463460
throw new GraphQLError('wrong credentials', {
464461
extensions: { code: 'BAD_USER_INPUT' }
465462
})
466463
}
467464

465+
const nonFriendAlready = (person) =>
466+
!currentUser.friends.map(f => f._id.toString()).includes(person._id.toString())
467+
468468
const person = await Person.findOne({ name: args.name })
469469
if ( nonFriendAlready(person) ) {
470470
currentUser.friends = currentUser.friends.concat(person)

0 commit comments

Comments
 (0)