I am testing out sending transactions using ReactJS, im new to React so trying to get an understanding on how this would work.
I have a URL paramater -
www.mysite.com?value=10
I can grab that parameter using -
const search = window.location.search;
const params = new URLSearchParams(search);
const value = params.get('value');
And if I console log it I get the correct value -
console.log(value); > 10
But I want to pass the "value" variable to a function on this page -
const sendNewTransaction: RawTransactionType = {
receiver: "{my address}",
data: "Send",
value: value.valueOf(),
gasLimit: 250000000,
chainID: chainId.valueOf(),
gasPrice,
version,
};
If I just create a new variable for value it works, but not when passing the URL parameter variable.
const value = "10"; > This works
const value = params.get('value'); > This doesnt work
The error I get is -
Object is possibly 'null'. TS2531
So basically it's saying theres no value right, since it says NULL? Does it have to do with the working value being a string?