Skip to content

Commit

Permalink
name must be unique
Browse files Browse the repository at this point in the history
  • Loading branch information
runely committed Jun 10, 2022
1 parent 7d0c723 commit 61e55fc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/mocks/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,15 @@ export const handlers = [
)
}

const { fullitem } = getReqSearchParams(req)
const apiKeys = get({ top: getTop(req), type: 'apikeys' })
if (apiKeys.data.find(key => key.name === req.body.name)) {
return res(
ctx.status(400),
ctx.json({ message: 'Error: name must be unique' })
)
}

const { fullitem } = getReqSearchParams(req)
const copyApiKey = apiKeys.data.length > 0 ? apiKeys.data[0] : _apikeys[0]
const newApiKey = JSON.parse(JSON.stringify(copyApiKey))

Expand Down

0 comments on commit 61e55fc

Please sign in to comment.