I have a dotnet core and react application, in which I have this service :
[HttpPost("[action]")]
public string UpdateUserLangage(string liste)
{
if(liste != null )
{
return liste;
}
else
{
throw new ArgumentNullException();
}
}
I tried to call this service using axios and fetch library :
axios
axios.default.post('api/preference/UpdateUserLangage', "test" )
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
fetch
fetch('api/preference/UpdateUserLangage', {
method: 'post',
body: JSON.stringify("test")
}).then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
As a result, I get an error :
The parameter liste
is always null so I get the error !
How can I fix this issue?
Thanks,