Skip to content

Instantly share code, notes, and snippets.

@vmussak

vmussak/request.js

Last active Apr 2, 2018
Embed
What would you like to do?
Request API Bitbucket
module.exports = {
buscarRepositorios
}
const request = require('request-promise');
async function buscarRepositorios(respostas) {
let token = await buscarToken(respostas.username, respostas.password);
let options = {
uri: `https://api.bitbucket.org/2.0/repositories/?role=${respostas.role}&pagelen=${respostas.pagelen}`,
headers: {
'Authorization': `Bearer ${token}`,
},
json: true
};
let repositories = await request(options);
if(respostas.somenteNome)
{
let repoName = [];
repositories.values.map((repo) => {
repoName.push(repo['full_name'])
});
return repoName;
}
return repositories.values;
}
async function buscarToken(username, password) {
//aqui retornamos o token, acreditem! :)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.