Discuss Scratch

kvackkvack
Scratcher
500+ posts

scratch-api help?

Here's my code:
var Scratch = require('scratch-api');
username = "kvackkvack";
password = "Removed by a friendly scratcher";
Scratch.createUserSession(username, password, function(err, user) {
  if (err) { console.log("Error: " + err) }
  console.log(user);
});
When I run it, I get the error:
TypeError: scratch.createUserSession is not a function.
Help?

Last edited by kvackkvack (Nov. 13, 2015 15:30:11)

WooHooBoy
Scratcher
1000+ posts

scratch-api help?

what version are you using? I think this is for <1.0.3

considered harmful
kvackkvack
Scratcher
500+ posts

scratch-api help?

WooHooBoy wrote:

what version are you using? I think this is for <1.0.3
Ah. Using the latest version, updated it today because it wasn't working.
What'd be the equivalent in the newer versions?
WooHooBoy
Scratcher
1000+ posts

scratch-api help?

kvackkvack wrote:

WooHooBoy wrote:

what version are you using? I think this is for <1.0.3
Ah. Using the latest version, updated it today because it wasn't working.
What'd be the equivalent in the newer versions?
I have no idea, RTM

considered harmful
robinp
Scratcher
100+ posts

scratch-api help?

You posted your password! D:
I'd recommend you change it..

System Administrator | Portfolio | My Blog | Web Developer
WooHooBoy
Scratcher
1000+ posts

scratch-api help?

robinp wrote:

You posted your password! D:
I'd recommend you change it..
oh whoops too late for me to steal notify them

considered harmful
robinp
Scratcher
100+ posts

scratch-api help?

WooHooBoy wrote:

robinp wrote:

You posted your password! D:
I'd recommend you change it..
oh whoops too late for me to steal notify them
:p

The reason why I removed it for him

Anyways, to actualy help with the error, if you are using almost any linux distro, install the nodejs package, not the node package.

Last edited by robinp (Nov. 13, 2015 15:43:52)


System Administrator | Portfolio | My Blog | Web Developer
kvackkvack
Scratcher
500+ posts

scratch-api help?

robinp wrote:

WooHooBoy wrote:

robinp wrote:

You posted your password! D:
I'd recommend you change it..
oh whoops too late for me to steal notify them
:p

The reason why I removed it from him
Oh whoops… I'm stupid. Thanks. XD
robinp
Scratcher
100+ posts

scratch-api help?

anyways, I think it was Scratch.create()?

var Scratch = require('scratch-api');
username = “kvackkvack”;
password = “Removed by a friendly scratcher”;
Scratch.create(username, password, function(err, user) {
if (err) { console.log(“Error: ” + err) }
console.log(user);
});

System Administrator | Portfolio | My Blog | Web Developer
kvackkvack
Scratcher
500+ posts

scratch-api help?

Never mind, installed an earlier version of it instead and it all worked.
Maybe a dumb solution, but oh well.
kvackkvack
Scratcher
500+ posts

scratch-api help?

So… I need help again. (sorry)
var Scratch = require('scratch-api');
username = "kvackkvack";
password = hidden;
Scratch.createUserSession(username, password, function(err, user) {
  if (err) { console.log(err) }
  user.cloud(project_id_here, function(err, cloud) {
	console.log(cloud.variables);
  });
  cloud.end();
});
This outputs {} even in projects that do have cloud variables.
Help ples.
jTron
Scratcher
100+ posts

scratch-api help?

kvackkvack wrote:

So… I need help again. (sorry)
var Scratch = require('scratch-api');
username = "kvackkvack";
password = hidden;
Scratch.createUserSession(username, password, function(err, user) {
  if (err) { console.log(err) }
  user.cloud(project_id_here, function(err, cloud) {
	console.log(cloud.variables);
  });
  cloud.end();
});
This outputs {} even in projects that do have cloud variables.
Help ples.
Not sure if it's your problem, because it seems like it should just throw an error, but what's that cloud.end() doing there?
Cloud isn't defined in that scope, and anyway that will run before the console.log.

clipd • osx clipboard manager and history

;
MathWizz
Scratcher
100+ posts

scratch-api help?

*sigh* This is what happens when I change the implementation slightly. Don't downgrade, do it the right way:
var Scratch = require('scratch-api');
username = "kvackkvack";
Scratch.UserSession.load(username, function(err, user) {
if (err) { console.log("Error: " + err) }
console.log(user);
});
You never have you save your password in code now.

kvackkvack wrote:

var Scratch = require('scratch-api');
username = "kvackkvack";
password = hidden;
Scratch.createUserSession(username, password, function(err, user) {
  if (err) { console.log(err) }
  user.cloud(project_id_here, function(err, cloud) {
	console.log(cloud.variables);
  });
  cloud.end();
});
This outputs {} even in projects that do have cloud variables.
The variables exist, they just aren't visible when printed. I fixed that in the latest version.

Last edited by MathWizz (Nov. 13, 2015 17:59:50)


running Chromium 42.0.2311.90 with Flash Player 15.0.0.189 on Arch Linux 3.19.5-1-ck
MathWizzJsScratch && sb.js & Amber (coming soon! maybe)
kvackkvack
Scratcher
500+ posts

scratch-api help?

MathWizz wrote:

*sigh* This is what happens when I change the implementation slightly. Don't downgrade, do it the right way:
var Scratch = require('scratch-api');
username = "kvackkvack";
Scratch.UserSession.load(username, function(err, user) {
if (err) { console.log("Error: " + err) }
console.log(user);
});
You never have you save your password in code now.

kvackkvack wrote:

var Scratch = require('scratch-api');
username = "kvackkvack";
password = hidden;
Scratch.createUserSession(username, password, function(err, user) {
  if (err) { console.log(err) }
  user.cloud(project_id_here, function(err, cloud) {
	console.log(cloud.variables);
  });
  cloud.end();
});
This outputs {} even in projects that do have cloud variables.
The variables exist, they just aren't visible when printed. I fixed that in the latest version.
Ah. Sorry, and thank you!

Powered by DjangoBB