javascript – How to connect my React App to Azure sql database (using Endpoints)
I am struggling to connect to my Azure sql db, and error message on the console is pointing to this:
const saveSurveyResults = useCallback(async (formattedResponses) => {
const apiUrl = ${config.server}/saveSurveyResults;
console.log('Saving...');
try {
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ surveyResponses: formattedResponses }),
});
if (response.ok) {
console.log('Survey results saved successfully');
} else {
console.error('Error:', response.statusText);
}
} catch (error) {
console.error('Error:', error);
}
}, []);
What could be the issue?
I would like to populate the Azure sql database with questions and answers user provided by the user.
Read more here: Source link
