Answer the question
In order to leave comments, you need to log in
Convert JSON object to string and output?
Hello. Please tell me what to do!
There is a task. "Pull out" information from the JSON file and enter the necessary data in the popup, but one of the properties of the object contains a bunch of other objects (In general, this should be a code example)
Example:
This is the data of the object and its properties
"registration":{
"link":"/api/auth/registration",
"api":{
"result": true,
"data": {
"name": "test",
"email": "[email protected]",
"api_token": "dYb4HQMwIZ0YXtkEBNQnsuekupAwCuMykWUFO6xB0kgHYqvgylGIFzLT8WO9",
"id": 34
},
"code": 0
}
},
const xhr = new XMLHttpRequest;
xhr.responseType = 'json';
xhr.addEventListener('load', function(){
window.api_schema = xhr.response;
for(let btn of btns){
btn.addEventListener('click', () => {
let content = btn.dataset.api;
modalLink.innerHTML = window.api_schema[content].link;
JSON.stringify(window.api_schema[content].api)
textApiCode.innerHTML = window.api_schema[content].api;
ModelPrimer.classList.remove('api-modal-none');
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question