Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Interaction With Scratch Does Not Work #31

@Ocean-OS

Description

@Ocean-OS

I am working on making an API that will give the user the number of messages they have. I have the following code:

var Scratch = require('scratch-api');
var fetch = require('node-fetch');
Scratch.UserSession.load(function(err, user) {
  user.cloudSession(526698636, function(err, cloud) {
    cloud.on('set', function(name, value) {
      console.log(name, value);
      Scratch.CloudSession.get('☁ r').onchange = function(){
      var i = Scratch.CloudSession.get('☁ user').toString();
      var s = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-", "_"];
      i = i.split('123456789');
      var e = 0;
      while(e < i.length){
        e[e] == s[Number(i[e])+1];
        i++;
      }
      i = i.toString();
        fetch('https://api.scratch.mit.edu/users/' + i + '/messages/count')
        .then(res => res.text())
        .then(text => {
          
          var t = text.split('{')[1].split(':')[1].split('}')[0];
          Scratch.CloudSession.set('☁ cloud data', t);
          Scratch.CloudSession.set('☁ r', 0);
    });
  }
});
})
})

However, it does not seem to work. Here is the project: API test What should I do to fix it? Where is the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions