Share. Learn. Grow.
Connect with fellow Tuwaiq students, showcase your projects, and collaborate on amazing code.
Featured Student Projects
AI/ML
3 days ago
Sentiment Analysis Tool
Python-based NLP tool that analyzes text sentiment with 90% accuracy.
24
8
Web Dev
1 week ago
E-commerce Platform
React + Node.js full-stack e-commerce solution with payment integration.
42
15
Mobile
2 weeks ago
Fitness Tracker App
Flutter application that tracks workouts and nutrition with beautiful UI.
36
11
Share Your Code Snippets
Ahmed Al-Mansour
Posted just now
React Custom Hook for API Calls
Here's a reusable hook I created for handling API requests in React applications. It includes loading states, error handling, and cancellation.
import { useState, useEffect } from 'react';
function useApiCall(apiFunc) {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const execute = async (...args) => {
try {
setLoading(true);
const result = await apiFunc(...args);
setData(result);
return result;
} catch (err) {
setError(err);
throw err;
} finally {
setLoading(false);
}
};
return { data, loading, error, execute };
}
export default useApiCall;
Community Chat
Tuwaiq Coders Chat
12 online
Sarah_K 2 mins ago
Has anyone worked with Next.js API routes? I'm having trouble with middleware...
You 1 min ago
Yeah! What specific issue are you facing? I implemented them in my last project.
Moha_Dev 30 secs ago
Check out this awesome resource for Next.js: https://nextjs.org/docs/api-routes/introduction