您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. };