You got two good options. Either, you accept it as a past mistake and remember to not do something like it in the future and just let it be. Or you go fix it now. Beeing undecided will only make it worse.
Honestly just press f12 on id, rename it to id2. Press f12 on token, rename it to id, then rename id2 to token. Do the same on the backend, case closed.
If your ide does renaming symbols on another button search for that or use for a moment the settings from vs code (because there its f12)
Because everything works, the correct data goes to the correct places. You just have to rename the variables.
That is... a terrible idea... You're choosing to to do this name swap on token and id, 2 very common keys. You may very easily break many API contracts that had nothing to do with this swapped id and token portion.
F12 changes the symbol not everything that is called id or token. The ide can figure out how the data flows it wont change occurances that would create problems
const someVar = {id} shouldnt be valid js. This is set like syntax from python. Js sets need to be created with new Set()
And if it were a shorthand (when destructuring for example) it maps the old to the new.
so const {token} = tokenObject //{token:unknown}
turns into const {token:id} = tokenObject
I agree if keys from objects get changed then the data flow could get corrupted. But that just doesnt happen. Because you are only renaming a variable.
I am not sure right now what reflection is though
Oh nvm looked it up, yeah that just doesnt get influenced at all. Because as said, we arent talking about keys here.
We are talking about variables, and yes variables can use their values for keys, but that isnt their name, thats still just what they represented. Even if this python set like syntax worked.
const token = {token}
The variable token would have {value of token:value of token}
const someVar = {id} is absolutely valid JS and has been for at least 10 years now. This syntax defines a property called id whose value is that of the variable called id in scope.
184
u/mxgaming01 Sep 21 '26
Yes, this is actually my code. And the joke is that both of them are 32-character random strings AND they get name-swapped again in the backend ðŸ˜
445
u/GabiTheProgrammer Sep 21 '26
...and utility functions for conversion IDtoToken and TokentoId (with lower d at the end, obviously).
74
u/k819799amvrhtcom Sep 21 '26
The equivalent in English would be:
14
u/realmauer01 Sep 21 '26 edited Sep 22 '26
Honestly just press f12 on id, rename it to id2. Press f12 on token, rename it to id, then rename id2 to token. Do the same on the backend, case closed.
If your ide does renaming symbols on another button search for that or use for a moment the settings from vs code (because there its f12)
Because everything works, the correct data goes to the correct places. You just have to rename the variables.
9
u/italkstuff Sep 21 '26
Feels good to fix this kind of shenanigans
6
u/throwsupstaysup Sep 22 '26
"if code is hard to write, it should be hard to read"
11
u/davak72 Sep 21 '26
shudders
3
u/TWHRodney Sep 22 '26
Balanced in line length
7
u/discordianofslack Sep 21 '26
Have you tried: "token": token; "id": id?
2
u/ligma_then_sugma Sep 22 '26
you might not like it, but this is what peak efficiency looks like
2
u/MeikelLP Sep 23 '26
Reminds me how in Azure OpenAI SDK "deploymentName" is a synonym for ai model name but "model" is only for ai model name
1
u/Pizza_Secretary9621 Sep 21 '26
Hey ! That's mine !
1
u/Kadabrium Sep 22 '26
"Token": Cash, "Cash": Token
1
u/Traditional-Poet5461 Sep 22 '26
Try it on Jev
1
u/TheSharpestHammer Sep 22 '26
import pandas as np
import numpy as pd
1
u/redditor_286 Sep 23 '26
var id_token = token + id;
1
u/Apprehensive_Bit7392 Sep 23 '26
Somewhere downstream, something already swaps them back. Fix it and you break production.
-1
u/mlucasl Sep 21 '26
What do you mean by "Codels"