I’m receiving some text from an API with JavaScript.
I need to convert this text into a JavaScript array to use it. Currently I can get the text but I need an extra step to convert it into a JavaScript array so I can console.log() it.
// API response. Note there are no quotes around it, it is exactly as is below
//["hi ",["hi medicaid","hi mama","hi in french","hi in spanish","hi in japanese","hi there","hi mom","hi in chinese"],"search"]
const response = await fetch("/autocomplete.php", {
method: "POST"
});
const data = await response.text();
// Breaks down here
console.log(data[1]); // This logs: "