In Javascript, I have a file resulting from using Axios.get command from a loop, but I can’t get the data inside it.
I can see the file at console.log(Authors), this is it:
Authors:
[]
0:
config: {transitional: {...}, adapter:Array(2), transformRequest: Array(1),timeout: 0,
data: Array(2)
0: {Author_name:"Mark", Author_lastName: "Twain", title:"Tom Sawyer"}
1: {Author_name:"Mark", Author_lastName: "Twain", title:"Huckleberry Finn"}
[[Prototype]]: Array(0)
headers: AxiosHeaders {access-control-headers: "*", access-control-allow-methods: "*",
request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials
status: 200
statusText: "OK"
[[Prototype]]: Object
1:
config: {transitional: {...}, adapter:Array(2), transformRequest: Array(1),timeout: 0,
data: Array(2)
0: {Author_name:"Edgar Allan", Author_lastName: "Poe", title:"The Black Cat"}
[[Prototype]]: Array(0)
headers: AxiosHeaders {access-control-headers: "*", access-control-allow-methods: "*",
request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials
status: 200
statusText: "OK"
[[Prototype]]: Object
I tried to get the variables inside “data” but couldn’t. I can’t understand how the array is composed. Almost every attempt to capture the data results “undefined”
Authors[data] –> “data” is not defined no-undef
or
Authors[0] –> undefined
I tried to get something like this:
books = [{Author_name:”Mark”, Author_lastName: “Twain”, title:”Tom Sawyer”}, {Author_name:”Mark”, Author_lastName: “Twain”, title:”Huckleberry Finn”}, {Author_name:”Edgar Allan”, Author_lastName: “Poe”, title:”The Black Cat”}]