Find the value returned via REST and insert into an input

0

I'm looking for, via RESTful, the id value of a user registered in an API. Now I have to enter this value into an input HTML. I'm trying this way:

I get the value of the variable in a tag with the class (value) and id (name)

and the value usually appears on the screen.

I have the input where I want to insert this value which is;

<input class="campo" type="text" value="">

And you have the JavaScript where I try to do this insertion that is;

let novoValor = document.querySelector(".valor").value; 
console.log(novoValor); 
let campo = document.querySelector(".campo");

campo.value = novoValor;

If I give a console.log(novoValor) it appears in the browser console:

<p data-brackets-id="1122" class="valor" id="id">6</p>

That's the exact id I'm looking for right now. But in the input instead of the value 6 that is the user id, this message "undefined" appears

Can anyone help me?

    
asked by anonymous 22.01.2018 / 20:06

0 answers