• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

MMM-Stock Cannot read property 'toLowerCase'

Scheduled Pinned Locked Moved Troubleshooting
34 Posts 2 Posters 7.4k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Away
    sdetweil @brendan_c23
    last edited by sdetweil Mar 5, 2021, 5:41 PM Mar 5, 2021, 4:54 PM

    @brendan_c23 usually this happens when a module retrieves data and EXPECTS success, but never really checks, or the data changes format.

    this specific error is related to a string (“abcdefgh”) and wanting to convert all the chars to lowercase before comapring… BUT the string didn’t get created…

    in json data its like this
    if(json_data.key.toLowerCase() ==‘test’)
    but the item changed name to Key, so its undefined.toLowercase()…

    or key is not a string anymore,
    but an object {}

    net, the code has to change

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    B 1 Reply Last reply Mar 5, 2021, 8:34 PM Reply Quote 1
    • B Offline
      brendan_c23 @sdetweil
      last edited by Mar 5, 2021, 8:34 PM

      @sdetweil Could you help guide me on how to fix the code? Would you like me to post the .js file?

      S 2 Replies Last reply Mar 5, 2021, 8:40 PM Reply Quote 0
      • S Away
        sdetweil @brendan_c23
        last edited by Mar 5, 2021, 8:40 PM

        @brendan_c23 which module is that

        this one works fine (with the example stocks)

        https://github.com/hakanmhmd/MMM-Stock

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • S Away
          sdetweil @brendan_c23
          last edited by sdetweil Mar 5, 2021, 8:50 PM Mar 5, 2021, 8:48 PM

          @brendan_c23 ok, I see the error on refresh…

          change line 90 from

          	if(this.config.currency.toLowerCase() != "usd"){
          

          to

          	if(that.config.currency.toLowerCase() != "usd"){
          

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          B 1 Reply Last reply Mar 5, 2021, 10:11 PM Reply Quote 1
          • B Offline
            brendan_c23 @sdetweil
            last edited by sdetweil Mar 6, 2021, 12:06 AM Mar 5, 2021, 10:11 PM

            @sdetweil Hey I tried that, now it says Cannot read property ‘toLowerCase’ of undefined at MMM-stock.js:90
            Any other suggestions?

            u are only changing the word this to the word that on that one line

            B 1 Reply Last reply Mar 5, 2021, 10:15 PM Reply Quote 0
            • B Offline
              brendan_c23 @brendan_c23
              last edited by Mar 5, 2021, 10:15 PM

              @brendan_c23 Uncaught TypeError: Cannot read property ‘toLowerCase’ of undefined

              S 1 Reply Last reply Mar 6, 2021, 12:11 AM Reply Quote 0
              • S Away
                sdetweil @brendan_c23
                last edited by Mar 6, 2021, 12:11 AM

                @brendan_c23 you are only changing one word
                ‘this’ to the word ‘that’ on one line

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                B 1 Reply Last reply Mar 6, 2021, 4:53 PM Reply Quote 0
                • B Offline
                  brendan_c23 @sdetweil
                  last edited by Mar 6, 2021, 4:53 PM

                  @sdetweil Yes I made that change, but the error was still coming up for me

                  S 1 Reply Last reply Mar 6, 2021, 4:53 PM Reply Quote 0
                  • S Away
                    sdetweil @brendan_c23
                    last edited by Mar 6, 2021, 4:53 PM

                    @brendan_c23 show me those 10 lines

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    B 1 Reply Last reply Mar 6, 2021, 4:56 PM Reply Quote 0
                    • B Offline
                      brendan_c23 @sdetweil
                      last edited by Mar 6, 2021, 4:56 PM

                      @sdetweil //if another currency is required - usd is default
                      var differentCurrency = false;
                      if(that.config.currency.toLowerCase() != “usd”){
                      differentCurrency = true;
                      var requiredCurrency = this.config.currency.toUpperCase();
                      }

                      	for (var key in data) {
                      		if (!data.hasOwnProperty(key)) {continue;}
                      		var symbol = key;
                      		var obj = data[key];
                      		var current = obj[0];
                      		var prev = obj[1];
                      		var price = current["4. close"];
                      		var change = prev["4. close"] - current["4. close"];
                      
                      		var html = "";
                      		var priceClass = "greentext", priceIcon="up_green";
                      		if(change < 0) {
                      			priceClass = "redtext";
                      			priceIcon="down_red";
                      		}
                      
                      S 1 Reply Last reply Mar 6, 2021, 4:58 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 1 / 4
                      1 / 4
                      • First post
                        6/34
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy