React
import React, { useEffect, useState } from 'react';
import axios from 'axios';
const IpoList = () => {
const [ipos, setIpos] = useState([]);
useEffect(() => {
const fetchIpos = async () => {
try {
const response = await axios.get('https://api.ipoalerts.in/ipos?status=open', {
headers: {
'x-api-key': 'your_api_key_here'
}
});
setIpos(response.data.ipos);
} catch (error) {
console.error('Error fetching IPO data:', error);
}
};
fetchIpos();
}, []);
return (
<div>
<h1>IPO List</h1>
<ul>
{ipos.map(ipo => (
<li key={ipo.id}>{ipo.name}</li>
))}
</ul>
</div>
);
};
export default IpoList;