Skip to content

Farshad Bagdeli#136

Open
FBagdeli wants to merge 7 commits intoboolean-uk:mainfrom
FBagdeli:main
Open

Farshad Bagdeli#136
FBagdeli wants to merge 7 commits intoboolean-uk:mainfrom
FBagdeli:main

Conversation

@FBagdeli
Copy link

@FBagdeli FBagdeli commented Jul 2, 2024

No description provided.

}

const updateCustomer = async (req, res) => {
const id = Number(req.params.id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if req.params.id is not a number

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function isNumber(num) {
return !isNaN(num)
}

console.log( isNumber('hello') )

const { name } = req.body

if (!id || !name) {
return res.status(400).json({error : 'Fields are not correct!'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Must provide a name'

try {
const updatedCustomer = await updateCustomerDb(id, name)
if(!updatedCustomer) {
return res.status(404).json('Customer didnt Find!')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Customer not found'

}
res.status(201).json({customer : updatedCustomer})
} catch (error) {
res.status(500).json({error : 'something Went Wrong!'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Internal server error'

try {
const updatedMovie = await updateMovieDb(id, title, runtimeMins)
if(!updatedMovie) {
res.status(404).json({error : 'Movie not found!'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return res.status(404).json({error : 'Movie not found!'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants