Trying my first React Application.
I am getting the error when calling the API Gateway endpoint:
Endpoint works when I use Postman , Browser and Python Script
Error fetching session ID: Error: Failed to fetch
function App() {
const [faceLivenessAnalysis, setFaceLivenessAnalysis] = React.useState(null)
const [sessionId,setSessionId] = React.useState(null)
const [loading,setLoading] = React.useState(null)
useEffect(() => {
const fetchCreateLiveness = async () => {
try {
const response = await fetch('https://xxxx-api.us-east-1.amazonaws.com/dev', {
mode: 'no-cors'
});
if (!response.ok) {
throw new Error('Failed to fetch');
}
const data = await response.json();
const mockresponse= { sessionId:data.sessionId}
setSessionId(mockresponse);
setLoading(false);
console.log('session:', data.sessionId);
} catch (error) {
console.error('Error fetching session ID:', error);
setLoading(false);
}
};
fetchCreateLiveness();
}, []);