-1
I searched every corner of the network for an answer and couldn’t find one and created an application with React that calls an Asp.Net core Webapi, using Axios
. It turns out that the parameters do not arrive in the API method.
This is the call with Aces:
const config = {
headers: {
'Content-Type': 'application/json',
'crossdomain': 'true'
},
};
const params={
Email: email,
Password: password
}
await axios
.post(`${URL}?`,JSON.stringify(params), config)
.then((resp) => {
data = resp.data;
})
.catch(function(err) {
console.log(err);
}
});
This is the API Startup class
If anyone can help, I’d be grateful.
Thank you
pass like this on this line:
.post(
${URL},params, config)
– novic
Virgilio Novic.. Follows null fields in api.
– Allysson Ebling
Only works if I pass the 'https://localhost:44318/api/Authen/login URL? Email=teste@email&Password=test'
– Allysson Ebling
Maybe something is configured wrong in the API.
– Allysson Ebling
await Axios . post(
${URL}?email=${email}&password=${password}
) . then((Resp) => { date = Resp.data; })– Allysson Ebling
This way it works
– Allysson Ebling
I don’t know if it’s bad silver to wear like that
– Allysson Ebling
is bad practice and Asp controller has to be an object to work out now that I’ve noticed your code.
– novic
I switched to an Object and got the data, but how do I use it ? They’re coming in like this: Valuekind = Object : "{"Email":"testEmail","Password":"testNew"}".
– Allysson Ebling