Skip to content

Commit

Permalink
chore: take API uri from .env file (#275)
Browse files Browse the repository at this point in the history
* chore: take API uri from env file
  • Loading branch information
shootermv authored Dec 4, 2023
1 parent 819ea8c commit d04b1b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# solves issues with stylis-plugin-rtl : https://github.com/styled-components/stylis-plugin-rtl/issues/35#issuecomment-1550877823
GENERATE_SOURCEMAP=false
GENERATE_SOURCEMAP=false
VITE_BASE_PATH=https://open-bus-stride-api.hasadna.org.il
9 changes: 5 additions & 4 deletions src/api/agencyList.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { BASE_PATH } from './apiConfig'
export interface Agency {
date: string // example - "2019-07-01"
operator_ref: number // example - 25,
agency_name: string // example - "אלקטרה אפיקים"
}

let json: Promise<Agency[]>
let json: Agency[]

export default async function getAgencyList(): Promise<Agency[]> {
if (!json) {
json = fetch('https://open-bus-stride-api.hasadna.org.il/gtfs_agencies/list').then((response) =>
response.json(),
)
const response = await fetch(`${BASE_PATH}/gtfs_agencies/list`)
json = await response.json()
}

return json
}
2 changes: 1 addition & 1 deletion src/api/apiConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Configuration } from 'open-bus-stride-client'

//const BASE_PATH = 'http://localhost:3000/api'
export const BASE_PATH = 'https://open-bus-stride-api.hasadna.org.il'
export const BASE_PATH = import.meta.env.VITE_BASE_PATH
export const API_CONFIG = new Configuration({ basePath: BASE_PATH })

export const MAX_HITS_COUNT = 16

0 comments on commit d04b1b9

Please sign in to comment.