import apiEndpoints from '../apiEndpoints'; import { QuestionData } from '../../utils/interface/questionInterface'; interface QuestionResponse { message: string; question: { [key: string]: string }; } export const postQuestion = async ( questionData: QuestionData ): Promise => { const response = await fetch( `http://localhost:3000${apiEndpoints.question}`, { method: 'POST', body: JSON.stringify(questionData), headers: { 'Content-Type': 'application/json', }, } ); const data: QuestionResponse = await response.json(); if (!response.ok) { throw new Error(data.message || 'Something went wrong!'); } return data; };