Skip to content

Instantly share code, notes, and snippets.

@mverissimo
Last active May 24, 2018 13:48
Show Gist options
  • Save mverissimo/e4cd8e3e9cc8b9fc070fe9def106946d to your computer and use it in GitHub Desktop.
Save mverissimo/e4cd8e3e9cc8b9fc070fe9def106946d to your computer and use it in GitHub Desktop.
Cartola api
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);
}
};
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