Rewrite into Nocode

My backend dev person wrote this javascript for my login page. It works, but I wanted to see if this could be rewritten in weweb no code. My backend system uses GraphQL, thus the mutation references.

const username = variables[/* Email Input - value */ '92cf57d9-136f-459e-8f82-796b245b8ae3-value'];
 const password = variables[/* Password Input - value */ '9342cd38-107f-4602-bd80-749d66c52490-value'];

    const loginMutation = `
  mutation LoginUser($username: String!, $password: String!, $rememberMe: Boolean) {
    login(username:$username password: $password, rememberMe: $rememberMe) {
      __typename
      ... on CurrentUser {
        id
        identifier
        refreshToken
      }
    }
  }

    `;

    const variableData = {
      username,
      password,
    };

    const response = await axios.post('https://provider.modwalla.com/shop-api', {
      query: loginMutation,
      variables: variableData,
    });
    
    const loginResult = response.data.data.login;

return {
loginResult,
headers: response.headers
}

Hey,
thats totally doable in NoCode.
You can create a string/text variable containing your loginMutation
Then add the Rest API plugin.

Then on your workflow, you can have a REST API Request action, using a POST action, and two fields: one named query with your loginMutation varaible, and one names variables with an Object containing your username and password.

You can then access the result with result.data.login and put it inside a variable.

3 Likes