@metacall/protocol
Version:
Tool for deploying into MetaCall FaaS platform.
29 lines (28 loc) • 894 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const url_1 = require("url");
const protocol_1 = require("./protocol");
exports.default = async (email, password, alias, baseURL) => {
const request = {
email,
password,
alias
};
if (!baseURL.includes('localhost')) {
request['g-recaptcha-response'] = 'empty'; // TODO: Review the captcha
}
const res = await fetch(baseURL + '/signup', {
method: 'POST',
headers: {
Accept: 'application/json, text/plain, */*',
Host: new url_1.URL(baseURL).host,
Origin: baseURL,
'Content-Type': 'application/json'
},
body: JSON.stringify(request)
});
if (!res.ok) {
throw new protocol_1.ProtocolError('Signup failed', res.status, await res.text());
}
return await res.text();
};