export default class App extends Component {
state = {
data: [],
loading: true,
};
componentDidMount() {}
sendRequest = (data) => {
var req = unirest(
"POST",
"https://price-history-charts.p.rapidapi.com/ProductHistory"
);
req.query({
product_url: "",
s: data,
});
req.headers({
"x-rapidapi-host": "price-history-charts.p.rapidapi.com",
"x-rapidapi-key": "3c3ee8f241msh0ed0f77adc21aa7p18664ajsndbbf16033725",
"content-type": "application/x-www-form-urlencoded",
});
req.form({});
req.end((res) => {
if (res.error) throw new Error(res.error);
const { data } = res.body;
const data1 = JSON.parse(data);
console.log("data1[0]:", data1[0]);
this.setState({ data: data1 });
});
};