main.js (471B)
1 import * as etc from "/lib/etc.js" 2 import * as api from "/lib/api.js" 3 4 etc.handle_wrap(main) 5 6 function main() { 7 if (!api.authorized()) { 8 window.location.href = "/login" 9 } 10 11 api.fetch("POST", "users/" + localStorage.getItem("username") + "/services/billingportal") 12 .then(function(body) { 13 window.location.href = body.url 14 }) 15 .catch(function(err) { 16 console.error("Unable to display billing portal:", err) 17 etc.error("There was an unexpected error.") 18 }) 19 }