const API_URL = "/api/authenticate"

export function signin(username, password){

    return fetch(`${API_URL}`, {
		method: "POST",
        headers: {
			Accept: "application/json",
            'Content-Type': "application/json",
		},
        body: JSON.stringify({
            name: `${username}`,
            password: `${password}`
        })
	}).then(r =>{
        if(r.status >= 200 && r.status < 300){
            return r.json();
        }
        else {
            throw new Error(r.status);
        }
    });
}