const inputId = req.body.id as string | null;
const unitType = req.body.unit_type as string | null;
if (!inputId) {
res.status(200).json({
success: true,
data: {
name: "",
},
});
}
const result = IDResolverDatabase.find((d) => d.id === inputId);
res.status(200).json({
success: true,
data: {
name: result ? result.name + ", " + result.Publisher : "",
},
});
```text
## Step 2 - Create your ID Resolver Autocomplete Webhook
This webhook should take in a `name` (the current partially typed name) and a possibly null `unit_type` and return the array `results` which contains potential matches in the shape of `{name: string, id: string}`. It should return at most 100 results, and the length per item should be under 100 characters.
```js
const partialName = req.body.name as string | null;
const unitType = req.body.unit_type as string | null;
if (!partialName) {
res.status(200).json({
success: true,
data: {
results: [],
},
});
}
const results = IDResolverDatabase.filter((d) =>
d.name.match(new RegExp(`^${partialName}`))
).limit(100);
res.status(200).json({
success: true,
data: {
results: results.map((result) => {
return {
name: result.name + ", (" + result.Publisher + ")",
id: result.id,
};
}),
},
});