Hello,
I’m still a student and I have choosen fuse to develop my app.
A friend of mine is working on the API server and i am doing the app.
Login with facebook is working but we developed our own login solution ( where you can register etc … ).
I think that I don’t have the good logic behind. I am trying with a button to launch the API request but I don’t get anything.
Server side it’s working the user has been created but from my side i don’t get any awnser.
Any idea on how i should arrange that code ?
File connection (Where I manage all request to API ), I have something like that
It works when the app start but not when button clicked
What am I missing ?
fetch('http://localhost:5000/register', {
method: 'post',
headers: { "Content-type": "application/json"},
body: JSON.stringify({
username: 'user1',
password: 'Pass',
email: 'user@gl.com',
})
}).then(function(response) {
status = response.status;
response_ok = response.ok;
return response.json();
I don’t get anything in response.json()
}).then(function(responseObject) {
//
}).catch(function(err) {
console.log("error:");
console.log(err);
});
And the js file from where calling this function :
Register function called once a button is clicked.
function Register(arg) {
BackEnd.fetchFunction();
}
If you have any exemple about a good architecture I ll be glad.
Thanks for you help