UNPKG

rw-login

Version:

RW.Login - part of ReWidgets library to simplify account management with token authorization.

18 lines (17 loc) 477 B
export const loginApi = async (apiAuthUrl, creds) => { const fetchInit = { method: 'POST', headers: new Headers({ "Content-Type": "application/json" }), body: JSON.stringify({ "username": creds.username, "password": creds.password }) }; const response = await fetch(window.origin + apiAuthUrl, fetchInit); return { ok: response.ok, body: await response.json() } };