Skip to content

Instantly share code, notes, and snippets.

@nenodias
Created February 14, 2018 18:33
Show Gist options
  • Select an option

  • Save nenodias/4bc96be3a7d23cd092fe21f72e1cfcdc to your computer and use it in GitHub Desktop.

Select an option

Save nenodias/4bc96be3a7d23cd092fe21f72e1cfcdc to your computer and use it in GitHub Desktop.
let PORTA = '8080';
let HOST = 'localhost';
let servidor = "http://" + HOST + ":" + PORTA;
let headers = new Headers();
headers.append("Accept","application/json");
headers.append("Content-type","application/json");
let dadosLogin = {
"login":"MASTER",
"senha":"MSTR"
};
let config = {
method:'POST',
headers:headers,
body:JSON.stringify(dadosLogin)
};
let emitente = 1;
let produto = '11NA-70010.BR';
fetch(`${servidor}/supervisor/ws/login`, config).then(function(res){
return res.json();
}).then(function(retorno){
console.log(retorno);
return retorno.token;
}).then(function(token){
config['method'] = 'GET';
delete config['body'];
return fetch(`${servidor}/estoque/ws/estoque/visualizarEstoqueDisponivel?token=${token}&emitente=${emitente}&produto=${produto}`, config).then(function(res){
return res.json();
});
}).then(function(dados){
console.log(dados);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment