Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Help me understand this API error

January 25 (7 years ago)
Ravenknight
KS Backer
Hiya, new group taking on old campaign - I've created a copy of the last campaign and everything seemed to work perfect until I imported the maps and now the API hangs everytime. Can someone make sense of what this error message means? I rather not have to delete all the maps and start from scratch. ( It's a lot of maps )

For reference, the error message generated was: TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined at apiscript.js:14465:16 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:909:14) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1368:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Rd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)
January 25 (7 years ago)
Disable each API script and retry to see which is causing the error. 
January 25 (7 years ago)
Ravenknight
KS Backer
Yea, It's probably what I have to do. But there are so daaaamn many. :P
January 25 (7 years ago)
The Aaron
Pro
API Scripter
Disable All Scripts Bookmarklet:
javascript:$('button.active.togglescript').click();
Enable All Scripts Bookmarklet:
javascript:$('button.inactive.togglescript').click();

January 26 (7 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ooh, will that latter jumpstart a crashed API?
January 26 (7 years ago)
GiGs
Pro
Sheet Author
API Scripter
*quietly adds yet another of Aaron's posts to my sourcebook of useful code for roll20.*
January 26 (7 years ago)

Edited January 26 (7 years ago)
The Aaron
Pro
API Scripter

keithcurtis said:

Ooh, will that latter jumpstart a crashed API?
Only if at least one of the scripts is disabled.  What you really want would be something like:
javascript:($('button.savescript')[0]||{click:()=>{}}).click();
That will work, provided you have at least one script installed. =D
Actually, adjusted it to always work (well, not crash, anyway.  If you have no scripts, it will technically not restart them, but then, they aren't there at all, so restarting them wouldn't really do anything... =D)
I see it now a new book by The Aaron titled yes I got something for that.  You sir should sign write it up 
January 26 (7 years ago)
The Aaron
Pro
API Scripter
=D
January 26 (7 years ago)
Ravenknight
KS Backer
I'm amazed and pleased. Thanks Aaron. :)
January 26 (7 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

The Aaron said:

keithcurtis said:

Ooh, will that latter jumpstart a crashed API?
Only if at least one of the scripts is disabled.  What you really want would be something like:
javascript:($('button.savescript')[0]||{click:()=>{}}).click();
That will work, provided you have at least one script installed. =D
Actually, adjusted it to always work (well, not crash, anyway.  If you have no scripts, it will technically not restart them, but then, they aren't there at all, so restarting them wouldn't really do anything... =D)

Ah, I understand. I probably won't be using these, then. I usually keep several disabled at any given time.
January 26 (7 years ago)
The Aaron
Pro
API Scripter
To be clear, this will restart the API without changing the enabled/disabled state of any scripts:
javascript:($('button.savescript')[0]||{click:()=>{}}).click();
January 26 (7 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Cool. Thanks.

The Aaron said:

To be clear, this will restart the API without changing the enabled/disabled state of any scripts:
javascript:($('button.savescript')[0]||{click:()=>{}}).click();

Anyway to make this work if the API tab isn't the active one?  That would be really useful.  (Preferably w/o making it switch tabs as well, though that would be acceptable, if necessary.)

January 27 (7 years ago)
The Aaron
Pro
API Scripter

Three of Swords said:


Anyway to make this work if the API tab isn't the active one?  That would be really useful.  (Preferably w/o making it switch tabs as well, though that would be acceptable, if necessary.)

Yes, but it's far from trivial.  Would require a full blown extension for chrome or firefox to allow cross tab communication.

January 27 (7 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Or Applescript. :P

(Well, Ok, it would still switch tabs...)

The Aaron said:

Three of Swords said:


Anyway to make this work if the API tab isn't the active one?  That would be really useful.  (Preferably w/o making it switch tabs as well, though that would be acceptable, if necessary.)

Yes, but it's far from trivial.  Would require a full blown extension for chrome or firefox to allow cross tab communication.


Alright. Don't waste your time doing that then. I can change tabs and click a button occasionally.  Or I could put more error handling into my scripts...