Jump to content
McKay Development
johnnyJ

Getting error when try to use any methods for steam-user

Recommended Posts

Hi!When I try to use any steam-user methods I'm receiving this error https://imgur.com/4xqZZlb

Code:

function logout() {
  const remote = require('electron').remote;
  const SteamUser = require('steam-user');
  const client = new SteamUser();
  localStorage.setItem("userID", "");
  client.logOff();
  var window = remote.getCurrentWindow();
  window.close();
}

func set onclick event

Methods are working but only from the second clickevent on first im getting that error.

Share this post


Link to post
Share on other sites

Looks like you're executing the JavaScript in the browser context and not in the Node.js context.

Ok so now I'm using it in Node.js and my script started working with first click event but I'm still receiving that error and if I remove const SteamUser = require('steam-user');

const client = new SteamUser(); from logout() like this:
const SteamUser = require('steam-user');
const client = new SteamUser();
function logout() {
  const remote = require('electron').remote;
  localStorage.setItem("userID", "");
  client.logOff();
  var window = remote.getCurrentWindow();
  window.close();
}
Im getting Uncaught ReferenceError: client is not defined
Edited by johnnyJ

Share this post


Link to post
Share on other sites

I add reactJS to my project and I connect steam-user module and i also get this error https://i.imgur.com/46tHB1W.png

I'm running my project with npm start

import React, { Component } from 'react'
import LoginForm from './LoginForm'
import SteamGuardForm from './SteamGuardForm'

const SteamUser = require('steam-user')
let client = new SteamUser()

export default class Login extends Component {
  state = {
    accountName: "",
    password: "",
    steamGuardCode: ""
  }

  inputChangeHandler = (event) => {
    this.setState({
      [event.target.id]: event.target.value
    })
  }

  loginHandler = () => {
    // sessionStorage.setItem("promptSteamGuard", true)
  }

  render() {
    return(
      <div className="welcome-container">
        <LoginForm
          accountName={this.state.accountName}
          password={this.state.password}
          inputChange={this.inputChangeHandler}
          tryLogin={this.loginHandler}
        />
        <SteamGuardForm
          steamGuardCode={this.state.steamGuardCode}
          inputChange={this.inputChangeHandler}
         />
      </div>
    )
  }
}
"scripts": {
    "start": "nf start",
    "react-start": "react-scripts start",
    "electron-start": "node electron-wait-react",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "electron": "electron .",
    "ebuild": "yarn build && node_modules/.bin/build"
  },

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...