You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

postQuestionRequest.js 482B

12345678910111213141516171819202122
  1. import apiEndpoints from '../apiEndpoints';
  2. export const postQuestion = async (questionData) => {
  3. const response = await fetch(
  4. `http://localhost:3000${apiEndpoints.question}`,
  5. {
  6. method: 'POST',
  7. body: JSON.stringify(questionData),
  8. headers: {
  9. 'Content-Type': 'application/json',
  10. },
  11. }
  12. );
  13. const data = await response.json();
  14. if (!response.ok) {
  15. throw new Error(data.message || 'Something went wrong!');
  16. }
  17. return data;
  18. };