Unable to create user with code but able to do it postman

console

const userEmail = token.email;
    // first fetching user with email API working fine
    if (!(user?.data || []).length) {
        // No user found with given email
        const body = {                        
            "username": userEmail.split('@')[0] ?? '',
            "email": userEmail,
            "provider": "local",
            "confirmed": true,
                        "blocked": false,
                        password: process.env.NEXTAUTH_SECRET ?? 'password@123',
                        role: 'CUSTOMER'
                    }
                    console.log("body >> for USER POST", body);
                    let userCreated = await fetch(base_url + '/auth/local/register', {
                        method: "POST",
                        'Authorization': `Bearer ${process.env.NEXT_PUBLIC_STRAPI_TOKEN}`,
body: JSON.stringify(body)
                    });
                    userCreated = await userCreated.json();
                    console.log("userCreated >>", JSON.stringify(userCreated, null, 2));

response of userCreated

body >> for USER POST {
  username: 'reactdeveloper3',
  email: 'reactdeveloper3@gmail.com',
  provider: 'local',
  confirmed: true,
  blocked: false,
  password: 'mwC1jois2aN+LWAy3kDQCdC0rvWaDRSNsVV5su6qr90=',
  role: 'CUSTOMER'
}
userCreated >> {
  "data": null,
  "error": {
    "status": 400,
    "name": "ValidationError",
    "message": "3 errors occurred",
    "details": {
      "errors": [
        {
          "path": [
            "email"
          ],
          "message": "email is a required field",
          "name": "ValidationError"
        },
        {
          "path": [
            "username"
          ],
          "message": "username is a required field",
          "name": "ValidationError"
        },
        {
          "path": [
            "password"
          ],
          "message": "password is a required field",
          "name": "ValidationError"
        }
      ]
    }
  }
}

This topic has been created from a Discord post (1238192999049986168) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Also let me is this way correct becuase in future i want to create users with role MERCHANTS too where i will just change my code with same google OAuth Provider using refine.dev