搜索结果:
javascript
const searchForm = document.getElementById('search-form');
const resultList = document.getElementById('results');// 获取用户输入的城市和汽车品牌
const getCity = () => document.getElementById('city').value;
const getMake = () => document.getElementById('make').value;// 创建一个将城市和汽车品牌作为参数的 API 请求函数
const makeApiRequest = (city, make) => {const url = 'https://api.example.com/v1/repair-shops';const params = {city: city,make: make,};return fetch(url, {params: params,}).then(response => response.json()).catch(error => {console.error('Error fetching repair shops:', error);alert('获取汽车维修店信息时出错,请稍后再试。');});
};// 处理 API 响应并显示结果
const displayResults = (data) => {const repairShops = data.repairShops;// 清空上一次