Reputation: 1
so I've been working on a react App that uses Express as server to communicate with my sql database. Currently I am trying to retrieve all objects(products) for a user with this call in the frontend:Frontend axios call Here I'm retrieving a web3 walletaddress which logs correctly, and sending it with the call as a parameter.
Then my server looks like this: server side for the call It seems like my address variable returns as undefined although I've looked up multiple tutorials and this is the way how they get the parameters from the axios request body.
So like I said, I've tried logging the address variable in the frontend, and it returned the correct value of an address. I've also tried to not give the parameter as an object, so: just like "[localhost-call], address".
Can anyone help me get the address from the Axios request parameter?
Upvotes: 0
Views: 221
Reputation: 1063
You can't do that with GET.
I mean you can't pass parameters (like address
) on a GET
request, if you want to pass a parameter like you want you will need to use another method (such as POST
, PUT
, etc...) or you can still use GET
by using querystring (Check this link to have another tutorial)
Such as:
// Equivalent to `axios.get('https://httpbin.org/get?address=toto.com')`
const res = await axios.get('https://httpbin.org/get', { params: { address } });
Note the explicit use of
params
keyword
Upvotes: 0