Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratch-api help?
- kvackkvack
- Scratcher
500+ posts
scratch-api help?
Here's my code:
When I run it, I get the error:
TypeError: scratch.createUserSession is not a function.
Help?
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); });
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?
Ah. Using the latest version, updated it today because it wasn't working. what version are you using? I think this is for <1.0.3
What'd be the equivalent in the newer versions?
- WooHooBoy
- Scratcher
1000+ posts
scratch-api help?
I have no idea, RTMAh. Using the latest version, updated it today because it wasn't working. what version are you using? I think this is for <1.0.3
What'd be the equivalent in the newer versions?
considered harmful
- WooHooBoy
- Scratcher
1000+ posts
scratch-api help?
oh whoops too late for me to You posted your password! D:steal notify them
I'd recommend you change it..
considered harmful
- robinp
- Scratcher
100+ posts
scratch-api help?
:poh whoops too late for me to You posted your password! D:steal notify them
I'd recommend you change it..
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)
- kvackkvack
- Scratcher
500+ posts
scratch-api help?
Oh whoops… I'm stupid. Thanks. XD:poh whoops too late for me to You posted your password! D:steal notify them
I'd recommend you change it..
The reason why I removed it from him
- 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);
});
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);
});
- 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.
Maybe a dumb solution, but oh well.
- kvackkvack
- Scratcher
500+ posts
scratch-api help?
So… I need help again. (sorry)
This outputs {} even in projects that do have cloud variables.
Help ples.
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(); });
Help ples.
- jTron
- Scratcher
100+ posts
scratch-api help?
(sorry)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? So… I need help again.This outputs {} even in projects that do have cloud variables.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(); });
Help ples.
Cloud isn't defined in that scope, and anyway that will run before the console.log.
- 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:
You never have you save your password in code now.
var Scratch = require('scratch-api');
username = "kvackkvack";
Scratch.UserSession.load(username, function(err, user) {
if (err) { console.log("Error: " + err) }
console.log(user);
});
The variables exist, they just aren't visible when printed. I fixed that in the latest version.This outputs {} even in projects that do have cloud variables.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(); });
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
MathWizz — JsScratch && sb.js & Amber (coming soon! maybe)
- kvackkvack
- Scratcher
500+ posts
scratch-api help?
Ah. Sorry, and thank you! *sigh* This is what happens when I change the implementation slightly. Don't downgrade, do it the right way:You never have you save your password in code now.var Scratch = require('scratch-api');
username = "kvackkvack";
Scratch.UserSession.load(username, function(err, user) {
if (err) { console.log("Error: " + err) }
console.log(user);
});The variables exist, they just aren't visible when printed. I fixed that in the latest version.This outputs {} even in projects that do have cloud variables.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(); });
- Discussion Forums
- » Advanced Topics
- » scratch-api help?