So i'm trying to get specific string from api that uses json. Heres what im trying to do: HERES THE IDEA IM TRYING TO DO : https://us.mc-api.net/example/uuid So i want the mayed505 replaced by the name in the text box and submits when the button is clicked ( this is minecraft api which you replace PLAYERNAME and put someones name and all the information will appear.) https://us.mc-api.net/v3/uuid/PLAYERNAME
var getJSON = function(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
resolve(xhr.response);
} else {
reject(status);
}
};
xhr.send();
});
};
getJSON('https://us.mc-api.net/v3/uuid/mayed505').then(function(data) {
// ^^^^^^^^ I want that be replaced with the input text in HTML like:
//https://us.mc-api.net/v3/uuid/INPUT FROM TXT BAR
//alert('Your Json result is: ' + data.full_uuid); //you can comment this, i used it to debug
full_uuid.innerText = data.full_uuid; //display the result in an HTML element
}, function(status) { //error detection....
alert('Something went wrong.');
});
<div id="full_uuid" style="color:red"></div>
<input id="playerName" type="hidden name" value="Username">
<input data-inline="true" class="btn btn-primary" type="button" value="Submit to get UUID">