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

postQuestionRequest.js 432B

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