I'm trying to render an object with an array into an array (a JSON), that I receive from an API. I've tried a lot but I don't get with the solution.
This is the object format I receive:
{
"catalogue": [
[
"shoes.txt",
"trousers.txt",
"tshirts.txt"
]
]
}
This is the code I'm using to call the API and render the object:
import React, { Component } from "react";
import axios from "axios";
class Result extends Component {
constructor(props) {
super(props);
this.state = {
items: [],
};
}
componentDidMount() {
const URL = "http://localhost/catalogue";
fetch(URL)
.then((response) => response.json())
.then((data) => this.setState({ items: data }));
}
render() {
const catalogue = this.state.items.catalogue;
return <div>{catalogue}</div>;
}
}
export default Result;
The only I could show in the web is this:
shoes.txttrousers.txttshirts.txt
The view I can get is something like this:
shoes.txt
trousers.txt
tshirts.txt
Would somebody help me please? Thanks in advance.