Can't create new users (/api/auth/local/register

I’m trying to send a restapi fetch request (POST) to register a new user, and I’m getting a 400 response. I can’t understand what I’m doing wrong, though

const data = {
      username: "name",
      email: "email@mail.com",
      password: "hashedPassword",
    //   role: "Authenticated"
    }

    const url = "http://localhost:1337/api/auth/local/register";
    try {
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({ data }),
      });

      if (!response.ok) {
        const errorData = await response.json();
        throw new Error(errorData.message || "Response was not ok.");
      }

      const jsonResponse = await response.json();
      console.log("Success: ", jsonResponse);
    }
    catch (error) {
      console.log(error);
    }

(Reason why role: is commented out is because, to my understanding, if you leave it out of the request object, it uses the default option, right?)

Can anyone help with this? using strapi v5 rc

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

nvm i got it.
shouldnt be wrapping the payload in an object, my bad :cry:

[SOLVED] - Can’t create new users (/api/auth/local/register