fix search
This commit is contained in:
parent
e9e72d8cea
commit
12949c1bba
2 changed files with 14 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"stationId": "9192",
|
||||
"stationName": "Slussen",
|
||||
"refreshRate": 10000
|
||||
"stationId": "9182",
|
||||
"stationName": "Hökarängen",
|
||||
"refreshRate": 30000
|
||||
}
|
||||
|
|
@ -53,9 +53,16 @@ app.get('/api/sl/search', async (req, res) => {
|
|||
if (!query) return res.status(400).json({ error: 'Query required' });
|
||||
|
||||
try {
|
||||
const response = await fetch(`https://journeyplanner.integration.sl.se/v2/stop-finder?name_sf=${encodeURIComponent(query)}&format=json`);
|
||||
const response = await fetch(`https://journeyplanner.integration.sl.se/v2/stop-finder?name_sf=${encodeURIComponent(query)}&format=json&type_sf=any&any_obj_filter_sf=2`);
|
||||
const data = await response.json();
|
||||
res.json(data);
|
||||
const locations: any[] = data.locations || [];
|
||||
const StopLocation = locations
|
||||
.filter((loc) => loc.type === 'stop' && loc.properties?.stopId)
|
||||
.map((loc) => ({
|
||||
id: loc.properties.stopId.replace(/^1800/, ''),
|
||||
name: loc.disassembledName || loc.name,
|
||||
}));
|
||||
res.json({ StopLocation });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to search for station' });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue