История страницы
...
interface Bounds {
from_bound: { value: string };
to_bound: { value: string };
}
interface Options {
bounds: Bounds;
suggestion: Suggestion;
type: "address";
}
Пример:
Без форматирования |
---|
type getBoundedValue = (options: Options) => string; import { getBoundedValue, createSuggestions } from "@dadata/suggestions"; const bounds = { from_bound: { value: "region" }, to_bound: { value: "city" }, }; const suggestions = createSuggestions(input, { type: "address", formatSelected(suggestion) { // вернет значение подсказки от региона до города // в соответствии с переданными границами bounds return getBoundedValue(bounds, suggestion, "address"); }, }); |
...
interface API_OPTIONS {
url?: string;
headers?: Record<string, string> | (() => Record<string, string>);
token?: string;
serviceUrl?: string;
partner?: string;
timeout?: number;
}
type getLocation = (options?: API_OPTIONS) => Promise<Suggestion | null>;
Пример:
Без форматирования |
---|
import { getLocation } from "@dadata/suggestions"; const token = /* */; getLocation({ token }).then((location) => { if (location) console.log(location.data.city); }) |
...
Обзор
Инструменты контента