Guest User

Untitled

a guest
Apr 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. handleIdSearch(event){
  2. let valor = event.target.value;
  3. fetch("http://urlDaApi.com.br?idProduto="+valor).then( function(resposta){
  4. // Veio um objeto do tipo Response, precisamos transformá-lo em JSON
  5. // Response.json() retorna outra Promise
  6. return resposta.json();
  7. }).then( function(json){
  8. // Pegue os valores do JSON
  9. document.getElementById("outroInput").value = json.valorOutroInput;
  10. }).catch( function(error){
  11. throw error;
  12. });
  13. }
  14.  
  15. document.getElementById("campoIdProduto").addEventListener('focusout',
  16. // Callback do evento
  17. function(event){
  18. handleIdSearch(event);
  19. })
Add Comment
Please, Sign In to add comment