Get Github Pull Requests for Repository with React
This creates a web page with the list of Pull Requests of a private Repositry. Replace <username>, <repo> and <your access token> with the proper values.
import React, { useState, useEffect } from 'react'; function App() { const [pullRequests, setPullRequests] = useState([]); useEffect(() => { const fetchPullRequests = async () => { try { const response = await fetch('https://api.github.com/repos/<username>/<repo>/pulls', { headers: { Authorization: `Bearer <your access token>` } }); const data = await response.json(); setPullRequests(data.filter(pr => pr.state === 'open')); } catch (error) { console.error(error); } }; fetchPullRequests(); }, []); return ( <div> <h1>Open Pull Requests:</h1> <ul> {pullRequests.map(pr => ( <li key={pr.id}> <a href={pr.html_url}>{pr.title}</a> </li> ))} </ul> </div> ); } export default App;