I'm getting a value which is the username of an account and I want to place it in a text.
For example, the HTML code will look like this. Ignore the review_array[i].date_posted cause I already completed that part.
<small>by " + username + " @ " + review_array[i].date_posted + "</small>
I have a jquery function where I will be getting the username but I am clueless on how to place the username in. How do I somehow insert the username in?
here is the code for my function of getting the username
$(document).ready(function() {
var getProfile2 = new XMLHttpRequest();
getProfile2.open("POST", "http://127.0.0.1:8080/member", true);
getProfile2.setRequestHeader("Content-Type", "application/json");
getProfile2.onload = function() {
var profile2 = JSON.parse(getProfile2.responseText);
console.log(getProfile2.responseText);
username = profile2[0].username;
}
var payload = { token: token };
getProfile2.send(JSON.stringify(payload));
})
node.js to make date posted to get the timing now
var new = new Date();
function for getting date posted automatically
function fetchReviews() {
var request = new XMLHttpRequest();
request.open('GET', review_url, true);
//This command starts the calling of the reviews api
request.onload = function () {
//get all the reviews records into our reviews array
review_array = JSON.parse(request.responseText);
console.log(review_array);
};
request.send();
}