Having trouble syncing images and nicknames? Try using this:
https://www.npmjs.com/package/steamapi
New to promises and stuck at a point in your code?
Here is the snippet of your code:
const SteamAPI = require('steamapi');
const steam = new SteamAPI('my steam token');
// My image
const imageUser1= steam.getUserSummary("76561198145216800").then(function(k){
return k.avatar.large;
}).catch(function(){
console.log("Didn't make it")
})
imageUser1.then(function(u){
console.log("yes")
document.getElementById("Img1Credits1").src = "" + k;
})
// Another image
const imageUser2= steam.getUserSummary("76561198175487278").then(function(k) {
return k.avatar.large;
}).catch(function(){
console.log("Didn't make it")
})
imageUser2.then(function(u){
document.getElementById("Img1Credits2").src = "" + k;
})
// //\\--------------------------\\//
// My nickname
const nicknameFromAPI1= steam.getUserSummary("76561198145216800").then(function(k){
return k.nickname;
}).catch(function(){
console.log("Didn't make it")
})
nicknameFromAPI1.then(function(u){
var nickname1= document.getElementById("nickname1");
if (nickname1.innerHTML !== k) {
nickname1.innerHTML= k + " (original nickname: §^-|_*[(@ATTISALVA@)]*_|-^§)"
}
})
// Another nickname
const nicknameFromAPI2= steam.getUserSummary("76561198175487278").then(function(k){
return k.nickname;
}).catch(function(){
console.log("Didn't make it")
})
nicknameFromAPI2.then(function(u){
var nickname2= document.getElementById("nickname2");
if (nickname2.innerHTML !== k) {
nickname2.innerHTML= k + " (original nickname: Crowbaria)"
}
})
Can't figure out what's wrong with this code?
Using Browserify for translation and Watchify for quick changes, but still struggling?
Remember that you need to get values by returning them and use .then method multiple times.