Last active
May 24, 2018 13:48
-
-
Save mverissimo/e4cd8e3e9cc8b9fc070fe9def106946d to your computer and use it in GitHub Desktop.
Cartola api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
module.exports = class Cartola { | |
constructor(email, password) { | |
this.baseURL = ''; | |
} | |
auth(data, callback) { | |
const instance = axios.create({ | |
baseURL: 'https://login.globo.com/api', | |
headers: { | |
'Content-Type': 'application/json' | |
} | |
}); | |
const request = instance | |
.post('/authentication', { | |
payload: { | |
captcha: '', | |
email: data.email, | |
password: data.password, | |
serviceId: 438 | |
} | |
}) | |
.then(response => { | |
callback(response); | |
}) | |
.catch(err => { | |
callback(err); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Cartola = require('./auth'); | |
module.exports = (req, res) => { | |
const cartola = new Cartola(); | |
cartola.auth( | |
{ | |
email: 'user@dominio.com.br', | |
password: 'pass' | |
}, | |
response => { | |
const api = cartola.api(response.data.glbId, '/auth/liga', response => { | |
res.status(201).send(response.data); | |
}); | |
} | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment