I need help calling an RPC I created

want to know about the TypeScript natural import that is giving error is not working at all with the nakama server template with the RPCs

Example below of RPC file:

Import ‘nameClass’ from ‘./nameClass.ts’

function TestRpc(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, payload: string): string {
logger.info(“TestRPC called!”);
return JSON.stringify({ success: true, nameClass });
}

and whoever I initialize in main returns this error: ( Cannot locate the name ‘TestRpc’. Did you mean ‘testRpc’? )

Example below the main file

// Copyright 2020 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the “License”);
const testRpc = ‘testRpc_js’;

function InitModule(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, initializer: nkruntime.Initializer)
{

initializer.registerRpc(testRpc, TestRpc); -> here and the error( Cannot find the name 'TestRpc'. Did you mean 'testRpc'? main.ts(6, 7): 'testRpc' is declared here. )

initializer.registerMatch(matchIdentifyer, {
    matchInit,
    matchJoinAttempt,
    matchJoin,
    matchLeave,
    matchLoop,
    matchTerminate,
    matchSignal,
});

logger.info('SERVER INITIALIZED');

I just want to know why when I import a file into an RPC it is invalidating the RPC?

Hi @juniorbraz93.

Please can you try exporting your TestRpc function, e.g:

export function TestRpc(...

Then importing it in your main.ts file as so:

import { TestRpc } from './testrpc'; // ...or whatever your file is called

I don’t know if this is in nakama’s server or the script I made.

is giving this error: here is the error( I can’t find the name ‘TestRpc’. Did you mean ‘testRpc’? main.ts(6, 7): ‘testRpc’ is declared here. )