Make a "library" JS file and include this file on ...
# suitetalkapi
c
Make a "library" JS file and include this file on the script that is making the rest calls.