Register with JavaScript Cloud code

HI,
I’m currently working on a web application and I want to handle registration and user management using Backendless. I have written some JavaScript code for this and have deployed it.

Here is the code:

‘use strict’;

/**
*

  • @integrationName userRegistration

**/
‘use strict’;

const Backendless = require(‘backendless’);

class UserRegistration {

// Static Methode – wird automatisch exposed
static async registerNewUser(email, password) {
// Fallback auf Backendless interne Parameter für Invoke/REST
const args = typeof ___methodArguments !== ‘undefined’ ? ___methodArguments : {};
const userEmail = args.email || email;
const userPassword = args.password || password;

if (!userEmail || !userPassword) {
  throw new Error('Email und Passwort müssen angegeben werden.');
}

const user = new Backendless.User();
user.email = userEmail;
user.password = userPassword;

try {
  return await Backendless.UserService.register(user);
} catch (err) {
  throw new Error(`Benutzer konnte nicht registriert werden: ${err.message}`);
}

}
}

// Registrierung – alle static Methoden werden automatisch exposed
Backendless.ServerCode.addService(UserRegistration);

module.exports = UserRegistration;

Unfortunately, I keep getting the following error with the service:

400 - [registerNewUser] method does not exist in [UserRegistration] service or is not a function

I’ve already tried everything possible; can someone help me?

When I access the URL of the method, I get: {“code”:14002,“message”:“Service method not found”,“errorData”:{}}

Thank you very much in advance.

Hi @Patrick_Parzer

you need to delete the static keyword

Regards,
Vlad