Lesson:
Cross-Site Script Inclusion
Public previewWant everyone on your software team to learn this? Get completion tracking and compliance reporting with Hacksplaining for Teams. Free 14-day trial.
Train my teamApplication.jsxconst apiKey = 'c9e2d730-4aba-42b2-9711-26ad584cba35';
function App() {
const [message] = useState('Welcome, new user! Fetching your data...');
useEffect(() => {
// Load in data using the pre-populated API key.
fetch('/api/profile', {
headers: {
Authorization: `Basic ${btoa(`${apiKey}:`)}`,
},
}).then(loadWelcomePage);
}, []);
return (
<div className="component-app">
<Message value={message} />
</div>
);
}
createRoot(document.getElementById('root')).render(<App />);