/**
* Password Generator API
* GET https://api.globus.studio/v2/password
* GET https://api.globus.studio/v2/password?length=20
* Response: plain text password
*/
async function genPassword(length) {
const url = new URL('https://api.globus.studio/v2/password');
if (length) url.searchParams.set('length', length);
const res = await fetch(url);
return res.text();
}
// Default length
genPassword().then(p => console.log(p));
// Custom length
genPassword(10).then(p => console.log(p));