Skip to content

Commit

Permalink
Update data using API
Browse files Browse the repository at this point in the history
Move from downloading, unzipping and create the data in the project itself.
  • Loading branch information
Ru Chern Chong committed Nov 5, 2023
1 parent 0a3ee60 commit 5b7bca3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 50 deletions.
8 changes: 2 additions & 6 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { Infographic } from "@/components/Infographic";
import { getElectricCarRegistrationByMake } from "@/lib/getElectricCarRegistrationByMake";
import { BASE_URL } from "@/config";
import { API_URL, BASE_URL } from "@/config";
import { WebSite, WithContext } from "schema-dts";
import type { Car } from "@/types";

const Home = async () => {
// TODO: Temporary solution while building a more permanent one.
const electricCars: Car[] = await getElectricCarRegistrationByMake(
`https://raw.githubusercontent.com/ruchernchong/singapore-ev-trends/main/public/data/M03-Car_Regn_by_make.csv`,
);
const electricCars: Car[] = await fetch(API_URL).then((res) => res.json());

const jsonLd: WithContext<WebSite> = {
"@context": "https://schema.org",
Expand Down
1 change: 1 addition & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const BASE_URL: string = `https://singapore-ev-trends.ruchern.xyz`;
export const API_URL: string = `https://api.singapore-ev-trends.ruchern.xyz`;

export enum FUEL_TYPE {
DIESEL = "Diesel",
Expand Down
44 changes: 0 additions & 44 deletions lib/getElectricCarRegistrationByMake.ts

This file was deleted.

0 comments on commit 5b7bca3

Please sign in to comment.