Advertisement
Guest User

Untitled

a guest
Feb 16th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. export const loginServer=(username, password)=> {
  2. return fetch(`${httpUrl}/companies/login_check`, {
  3. method: 'POST',
  4. headers: {
  5. 'Accept': 'application/json',
  6. 'Content-Type': 'application/json',
  7. },
  8. body: JSON.stringify({
  9. username: username,
  10. password: password,
  11. })
  12. }).then((response) => {
  13. if (!response.ok) {
  14. throw new Error("User or password is incorrect!");
  15. }
  16. return response;
  17. }).then((response) => response.json()).catch(error => {
  18. console.log("Login error " + error);
  19. throw new Error("User or password is incorrect!");
  20. });
  21. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement