Browse Source

login: tweak requests

master
Guillermo Rauch 9 years ago
parent
commit
19f8d4c4d9
  1. 12
      lib/login.js

12
lib/login.js

@ -5,6 +5,8 @@ import fetch from 'node-fetch';
import { stringify as stringifyQuery } from 'querystring';
import chalk from 'chalk';
const URL = 'https://api.now.sh/registration';
const stdin = process.openStdin();
function readEmail () {
@ -19,13 +21,8 @@ function readEmail () {
async function getVerificationToken (email) {
const data = JSON.stringify({ email });
const res = await fetch('http://localhost:3001/', {
const res = await fetch(URL, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
},
body: data
});
@ -43,8 +40,7 @@ async function verify (email, verificationToken) {
token: verificationToken
};
const res = await fetch('http://localhost:3001/verify?' + stringifyQuery(query));
const res = await fetch(`${URL}/verify?${stringifyQuery(query)}`);
const body = await res.json();
return body.token;
}

Loading…
Cancel
Save