Ask coding questions

← Back to all posts
More Client-Side, Server-Side Communication Questions
h
RayhanADev

Heya, Ray again. I have another Server-Side, Client-Side problem that needs a bit of help. So I need to assign a variable “name” with information from localStorage so that it finds the correct document name in the database, but I don’t know how to send it to the function from client-side to server-side.

My relevant code (not sharing the Repl for security reasons):
Server Side Index.js

Client Side Index.js

That’s all the relevant information. Can someone help find the problem. Thanks,
~ Ray

Voters
RayhanADev
Comments
hotnewtop
RoninMartin

For business development it is very important to attract new customers and retain those that are there. To ensure that the client always has reliable support we use https://wow24-7.io/saas, our company's reputation is very important to us and that's why we choose the best outsourcing of customer support. Behind every big business there should be a strong saas support team.

TsunamiOrSumth

@RayhanADev hi if ur not busy can you check out something i am making :D

RayhanADev

@TsunamiOrSumth yeah sure why not. Invite me!

TsunamiOrSumth

@RayhanADev i invited

CSharpIsGud
RayhanADev

@CSharpIsGud gd, might I ask how you did this one xD? I swore I moved the multipliers.

CSharpIsGud

@RayhanADev POST /save-db

RayhanADev

@CSharpIsGud well um, can you help make this more secure xD.

CSharpIsGud

@RayhanADev Not sure that's even possible, it has to give a score or tell when a good thing is clicked at some point and both ways can be cheated

RayhanADev

@CSharpIsGud well then, don’t tell anyone what you know (I deleted like three versions of you but left one with leet xD). Um can you help with this Repl though, just like communication stuff.

CSharpIsGud

@RayhanADev Anyone who knows what inspect element is already knows lol

RayhanADev

@CSharpIsGud nono, can you help with server-side, client-side communication.

realTronsi

@Coder100 quick question, this isn't allowed right:

Coder100

@realTronsi wait what did he do

realTronsi

@Coder100 he posted the same post at least 4 times in talk already. (he deletes the other one and just reposts). I'm not sure if this is against ToS

Coder100

@realTronsi are the reposts deleted?

realTronsi

@Coder100 yes, but same exact post, every few hours I come on I swear I see the post near/at the top of new talk, so he's been reposting very frequently

Coder100

@realTronsi eh, seems like a strange way to get upvotes
but if he isn't like spamming the post, and instead silently spamming, mods can't really do anything about it

realTronsi

@Coder100 mmk, just a bit annoying since everytime I come on their tic tac toe game is on the top of the list

Coder100

ahhhhhh use the other function I gave you
and in your client side:

backend:

RayhanADev

@Coder100 it still throws an error? multiplier1 is not defined or something?

realTronsi

@RayhanADev lol not sharing repl for security reasons? You know you have to share the repl to enter the jam

RayhanADev

@realTronsi well...
fair enough. I’ll post it. Think you can help?

realTronsi

@RayhanADev maybe, I need to look at the context. Also whats your "security reason"?

RayhanADev

@realTronsi well the redeemable codes :D. Lol now you can see them.

realTronsi

@RayhanADev lol whats the point of the codes? Also you can just store them in .env files if you want lmao

RayhanADev

@realTronsi well can’t you see the .env if you look at the code editor xD.

realTronsi

@RayhanADev no the whole point of env files is to store keys and secrets that others can't access

RayhanADev

@realTronsi wait so rn you can’t see inside the .env file?

realTronsi

@RayhanADev no, otherwise what is the point of .env files

RayhanADev

@realTronsi wow, I serously misunderstand the code editor. Anyways, can you help? I posted the Repl in the answer.

realTronsi

@RayhanADev this doesn't have anything to do with repl or the code editor, it is the literal definition/use of .env file

realTronsi

@RayhanADev wait so whats your issue atm?

RayhanADev

@realTronsi nono smh I’m talking about my communication problem (in the code). The one I asked in the question.

Coder100
realTronsi

@RayhanADev whats the problem rn though? describe your issue other than "idk how"

RayhanADev

@realTronsi okay right now my problem is an “n” variable that contains the data from a Firebase Document. I’m trying to get the value of a specific object on that document, but it returns something like Cannot read property multipier1 of undefined. The error could be something wrong in the way I set up the variable or it could be something else in the code. (Which is why I said IDK, I don’t want to confuse anyone who tries.) So um, does that make sense?

realTronsi

@RayhanADev and where is this?

RayhanADev

@realTronsi okay, look at index.js line 59 for the getMultiplier Function, index.js line 144 for the app.get, and public/js/index.js for the fetch.

realTronsi

@RayhanADev you need better naming theres two index.js lol

RayhanADev

@realTronsi it doesn’t effect anything I tested it xD.

realTronsi

@RayhanADev btw you have a global variable named db and you also have a param named db, might cause problems idk

RayhanADev

@realTronsi So you find the problem?

realTronsi

@RayhanADev no idk but you have a global variable named db and a param named db, it probably wont affect anything but you should still rename to avoid confusing nodejs

RayhanADev

@Coder100 So I did what you said (a while back) and I started logging everything and req.body.name is undefined (in the app.get). That is the cause of all the errors! So my question is how do I fix it?

Coder100

@RayhanADev is your post request invalid

Coder100

make sure the body is at least:

@RayhanADev

RayhanADev

@Coder100 I don’t have a post request you didn’t say to...

Coder100
RayhanADev

@Coder100 yeah. Hop on the code you’ll see what I mean. I literally used what you put.