Attempt of kuala techs coding challenge using Nextjs
https://kuala-challenge.vercel.app/
- **Next.js' file-based router
- **SSR for fast page loads
- Next.js - Framework for server-rendered React applications
- React - JavaScript library for building UI components
- Tailwind CSS - Utility-first CSS framework
The project includes data-fetching utilities to streamline API calls. One such function, getMakes, is used to fetch vehicle makes from the API. Here's how it works:
import { VehicleMake } from "@/types";
const URL = `${process.env.NEXT_PUBLIC_KUALA_API_URL}/get-vehicle-makes`
const getMakes = async (): Promise<VehicleMake[]> => {
const res = await fetch(URL);
const result = await res.json();
return result.data;
};
export default getMakes;
- Environment Variables: Uses process.env.NEXT_PUBLIC_KUALA_API_URL for the API base URL, making it configurable based on the environment.
- TypeScript: Enforces type checking by specifying Promise<VehicleMake[]> as the return type, ensuring data consistency.
- Asynchronous Data Fetching: Uses async/await to handle asynchronous API calls smoothly
- Node.js >= 14
- Clone the repository
git clone https://github.com/RoyMtonga/kuala-challenge.git cd repo-name
- Install dependencies
npm install
- Set up environment variables
Create a .env.local file in the root of your project and add the environment variable. Here’s an example: ```env NEXT_PUBLIC_KUALA_API_URL=https://whitebook-engine.kuala.io
- Start the development server
npm run dev