Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handleIdSearch(event){
- let valor = event.target.value;
- fetch("http://urlDaApi.com.br?idProduto="+valor).then( function(resposta){
- // Veio um objeto do tipo Response, precisamos transformá-lo em JSON
- // Response.json() retorna outra Promise
- return resposta.json();
- }).then( function(json){
- // Pegue os valores do JSON
- document.getElementById("outroInput").value = json.valorOutroInput;
- }).catch( function(error){
- throw error;
- });
- }
- document.getElementById("campoIdProduto").addEventListener('focusout',
- // Callback do evento
- function(event){
- handleIdSearch(event);
- })
Add Comment
Please, Sign In to add comment