importing external javascript to google apps script

北慕城南 提交于 2019-11-27 11:43:12
owyongsk

Based on the answer here by Cameron Roberts, you can use the eval() function on the appscript UrlFetchApp function.

eval(UrlFetchApp.fetch('http://path.to/external/javascript.js').getContentText());

you actually can . In the script project create another new file and simply just paste the JavaScript library copying from the source and save it then start referencing it from other file. It is that simple.

Or you can create another project with the .js lib and publish it and reference that script from the caller project, I wont do that unless that needs to be shared in multiple projects.

Mogsdad

You cannot use external javascript libraries this way in Google Apps Script. (You can do so in html files used with the HtmlService. Since so much of Trello is client-side anyway, this may be just what you need.)

In server-side apps script, you should be able to access the library code using the technique from this answer. It doesn't say, but I'd imagine that you would put that eval outside of all functions in your script, to make the objects in the library available to the rest of your code.

Download them and put them in the script. The rest api is easy to use. Ive used trello rest from appscript.

youssef

Yes you can use JavasSript libraries in Google script. Copy all content of the libraries JavaScript and post it in new GS file.

You can try this 2 options:

Hope this helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!