Unable to modify images and nicknames that have been selected from the steamapi

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.

Answer №1

My code is being restricted by CORS, preventing it from functioning properly

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Click event triggered the function, however it was unable to modify the variable in $scope

<!doctype html> <html ng-app> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script> <script src="script.js"></script> </head> <body> <ul c ...

JavaScript does not support clicking on an iframe

Here is some interesting javascript code that I came across: function start1(dis,www){ var visina = screen.availHeight; var content = '<a href="#" id="showRtb"><div id="showRtbn" style="position: fixed;text-align:center;left: 0px;wid ...

Using conditional binding with AngularJS, the value will only be concatenated and bound if the property is not empty

As a beginner with Angular, I am attempting to link a string to a model as long as the value is not empty. This is successful for a single input, but I now want to merge multiple text inputs into a single string. <input type="text" ng-model="data.sou ...

Receiving an npm error code ELIFECYCLE while attempting to halt a process by pressing

My web scraping tool is crafted with puppeteer for the backend and inquirer.js for the CLI functionality. I want to ensure that users can smoothly exit the process without any errors by simply pressing CTRL + C. Everything works flawlessly when I run node ...

Implementing a hover effect for a link that triggers a pop-up window, similar to Facebook's feature where hovering over a link reveals options such as sending a message

As a rails programmer, I am working on creating a hover pop-up for links in my project. In this particular scenario, I have an array of users being displayed with various details such as user image and name. My goal is to have a pop-up window appear only w ...

Customizing validation rules in Nest.js

Here is a representation of the data shape: { "saturday": [ { "start": "10:00 AM", "end": "12:00 AM" } ], "sunday": [], ... } This structure defines my time-slot.interf ...

Error encountered while attempting to convert CSV file: InvalidStateError

I've implemented a JavaScript function to be triggered by the 'onclick' event of an HTML button: function exportReportData2() { if ($("#Report").val() != "") { var screenParametersList = buildScreenParameters(); var ...

Trigger an input file click automatically using vanilla JavaScript with an AJAX request in Google Chrome

Currently, my webapp operates in a way that every button click triggers an ajax request to the server. The server then validates and sends JavaScript code back to the client. Unfortunately, the framework I am using does not allow me to incorporate jQuery a ...

Selecting a radio button using information retrieved from a JSON source

I am working with a set of radio buttons that send data to the database in the form of 0 and 1 (1=Yes, 0=No). I want to retrieve this information from the database and highlight the appropriate radio button based on the saved value. Here is my code snippet ...

Tips for Removing node_modules Folder from Deeply Nested Directory on Windows

When attempting to delete the node_modules directory generated by running npm install: The file name(s) are too long for the file system. Consider relocating to a path with a shorter name, or rename the files to shorter names before trying again. I eve ...

Localhost parcel server failing to refresh

Currently, I am utilizing the parcel (v2.0.1) localhost server with hot module replacement for developing a basic web application using HTML, SASS, and JS. While the HMR functionality generally works well, there are instances where, especially after signif ...

Discover the art of utilizing two distinct binding strings, wherein upon the selection of either, the alternate binding string shall automatically be

Having to use two different bindingstrings is a requirement due to a tool used for creating PDFs. My objective is to have the corresponding bindingstring turn "Off" when a user clicks on either the Yes or No button, and have the clicked button turn to "Yes ...

Preserve the scroll location while adding new content to a list in AngularJS

I have been attempting to add new items to a list within a scrollable container using ng-repeat, with the most recent item appearing at the top. It is important that I am able to preserve the scroll position if the scrollbar is not at the very top when add ...

Identifying between a webview and browser on an Android device

I need to differentiate between a webview and a browser in Android to display a banner only for users accessing the app via a browser, not through a webview. I've tried using PHP code but it doesn't work as expected. Is there another method to a ...

Issue with PHP's ng-click not functioning properly with Angular JS's dynamic HTML generation

I'm just starting out with Angular JS. I'm trying to create an ng-click event in dynamically generated HTML from PHP, here's the code snippet. var app = angular.module('pageapp',[]); angular.module('pageapp') .filter(& ...

I am looking for a solution to transform JSON data into XML format using node.js

I'm looking to convert JSON data on my node.js server into an RSS feed. Can anyone recommend the most efficient method for accomplishing this task? Additionally, once the conversion is complete, I will need the RSS file to be outputted or overwritten. ...

Ensuring the canvas fits perfectly within its parent div

I am attempting to adjust my canvas to fit inside a div. // Make the Canvas Responsive window.onload = function(){ wih = window.innerHeight; wiw = window.innerWidth; } window.onresize = function(){ wih = window.innerHeight; wiw = window.innerWidth; } // ...

Monitoring user clicks using JavaScript code implemented

Currently, I am utilizing a JavaScript file to load on certain pages in order to track various events. Within this JavaScript file, there is a collection of selectors that have listeners attached to them. When these selectors are clicked, the tracking AP ...

The JavaScript loop does not update the value of a number input field

In an effort to save and retrieve data from local storage, I have implemented a loop that iterates through various fields in a dynamic table row. The process involves saving the data to local storage, clearing the table rows, recreating them for data retr ...

Is it possible to manipulate the carousel image within the div element?

I am working on a Bootstrap code snippet that showcases an image using the w-100 class to span the full width of the page. However, the challenge I'm facing is making sure the image is visible to users while keeping it small enough so they won't ...