# Update API Request - Next.js Course

**URL:** <https://forum.codewithmosh.com/t/update-api-request-next-js-course/22502>\
**Category:** Next.js\
**Created:** [September 14, 2023, 10:17am UTC](https://forum.codewithmosh.com/t/update-api-request-next-js-course/22502 "2023-09-14T10:17:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arabianoud](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@arabianoud](https://forum.codewithmosh.com/u/arabianoud)\
**Post date:** [September 14, 2023, 10:17am UTC](https://forum.codewithmosh.com/t/update-api-request-next-js-course/22502/1 "2023-09-14T10:17:42Z")

</div>

Hi Mosh,

In your Next.js Course, _Building APIs - 5: Updating an Object_ I noticed that we’re not actually updating anything. I was expecting to update the name which we set in `/users` here like this for example: `return NextResponse.json({ id: params.id, name: body.name });`.

Also, if you could add a category for Next.js please on this forum that’ll be hand.

Great course so far so thanks for putting this together!

```auto
export const PUT = async (request: NextRequest, { params }: { params: { id: number } }) => {
  // Validate the request body. If invalid, return 400 error
  const body = await request.json();
  if (!body.name) {
    return NextResponse.json({ error: 'Name is required' }, { status: 400 });
  }

  // If the ID doesn't exist, return 404 error
  if (params.id > 10) {
    return NextResponse.json({ error: 'User not found' }, { status: 400 });
  }

  // Otherwise fetch the user with the given ID and update the name with the name in the response body
  return NextResponse.json({ id: params.id, name: body.name });

  // Otherwise update the user and return
  // return NextResponse.json({ id: 1, name: body.name });
}

```
