Skip to content

Commit

Permalink
chore: take API uri from env file
Browse files Browse the repository at this point in the history
  • Loading branch information
shootermv committed Dec 4, 2023
1 parent 402fc1b commit d783c79
Show file tree
Hide file tree
Showing 3 changed files with 7 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_API_URI=https://open-bus-stride-api.hasadna.org.il/
8 changes: 4 additions & 4 deletions src/api/agencyList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ export interface Agency {
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(`${import.meta.env.VITE_API_URI}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_API_URI
export const API_CONFIG = new Configuration({ basePath: BASE_PATH })

export const MAX_HITS_COUNT = 16

0 comments on commit d783c79

Please sign in to comment.