Output in terminal: {}
My code
This function for get value from inputs and if button is clicked send to next func sendToStart()
let name_inp_val = document.querySelector('.name').value;
let gamecode_inp_val = document.querySelector('.gamecode').value;
sendToStart(name_inp_val, gamecode_inp_val);
}
On this function [ sendToStart() ] I get Client_IP with $.ajax() convert to string and send this all data to server, but sending don't working. What can I do for fix this?
function sendToStart(name, gamecode) {
// Get CLIENT IP FROM API.IPIFY.ORG
let ip_adress = "";
$.ajax({
url: "https://api.ipify.org?format=json",
type: "GET",
dataType: "json",
contentType: "application/json",
success: function(data) {
ip_adress = data.ip;
},
error: function(data) {
console.log(data);
}
});
// Send data to server
$.post("http://localhost:5000/api/start/", {"name": name, "gamecode": gamecode, "ip": ip_adress}, function(data) {
console.log(data);
});
}
export default sendToStart;
What I want?
But now on servger terminal I see: {}