Как получить доступ к значению Json Responce dict в Html скрипте

Мои представления django

def contact_otp(request):
        if request.method=="POST":
            data={}
            #
            return JsonResponse(data)


.then((response) => response.json())
          .then((data) => {
            console.log(data)
            const newVarPass = document.createElement("input")
            newVarPass.setAttribute('id','varPassID')
            newVarPass.setAttribute('value',`${data}`)
            newVarPass.value=`${data}`
            newVarPass.style.display="none"
            document.body.appendChild(newVarPass)
            alert("Check your Email We have send you the otp")
            console.log(data)
            
          })

    x = document.getElementById("varPassID")
                console.log(x)
                console.log("Lets check")

enter image description here

Как получить значения пары ключей json, которые я хочу иметь, которые присутствуют в данных json, я всегда получаю объект object в значении сейчас

document.getElementById("varPassID").innerText = data.data-token

Ссылка: https://www.w3schools.com/jsref/prop_node_innertext.asp

Вернуться на верх