Argument of type 'unknown' is not assignable to parameter of type 'string'
asked 230 days ago
0
12
Getting issue as indicated on the title on line 17 of this code block
1 const handleCreateQuestion = async (
2 data: z.infer<typeof AskQuestionSchema>
3 ) => {
4 startTransition(async () => {
5 if (isEdit && question) {
6 const result = await editQuestion({
7 questionId: question?._id,
8 ...data,
9 });
10
11 if (result.success) {
12 toast({
13 title: "Success",
14 description: "Question updated successfully",
15 });
16
17 if (result.data) router.push(ROUTES.QUESTION(result.data._id));
18 } else {
19 toast({
20 title: `Error ${result.status}`,
21 description: result.error?.message || "Something went wrong",
22 variant: "destructive",
23 });
24 }
25
26 return;
27 }
28
29 const result = await createQuestion(data);
30
31 if (result.success) {
32 toast({
33 title: "Success",
34 description: "Question created successfully",
35 });
36
37 if (result.data) router.push(ROUTES.QUESTION(result.data._id));
38 } else {
39 toast({
40 title: `Error ${result.status}`,
41 description: result.error?.message || "Something went wrong",
42 variant: "destructive",
43 });
44 }
45 });
46 };
1 const handleCreateQuestion = async (
2 data: z.infer<typeof AskQuestionSchema>
3 ) => {
4 startTransition(async () => {
5 if (isEdit && question) {
6 const result = await editQuestion({
7 questionId: question?._id,
8 ...data,
9 });
10
11 if (result.success) {
12 toast({
13 title: "Success",
14 description: "Question updated successfully",
15 });
16
17 if (result.data) router.push(ROUTES.QUESTION(result.data._id));
18 } else {
19 toast({
20 title: `Error ${result.status}`,
21 description: result.error?.message || "Something went wrong",
22 variant: "destructive",
23 });
24 }
25
26 return;
27 }
28
29 const result = await createQuestion(data);
30
31 if (result.success) {
32 toast({
33 title: "Success",
34 description: "Question created successfully",
35 });
36
37 if (result.data) router.push(ROUTES.QUESTION(result.data._id));
38 } else {
39 toast({
40 title: `Error ${result.status}`,
41 description: result.error?.message || "Something went wrong",
42 variant: "destructive",
43 });
44 }
45 });
46 };
0 Answers


No Answers Found
The answer board is empty. Make it rain with your brilliant answer.
1