PageSourceSearch

https://www.phenomenex.com/scripts/getParts.js

js phenomenex.com collected 2026-10-03 23:17:38 UTC 1,345 bytes, 48 lines download raw bytes

1// eslint-disable-next-line import/no-cycle
2import { getIdToken } from './auth.js';
3import buildErrorToast from './build-error-toast.js';
4import { getHostURL } from './scripts.js';
5
6export default async function getParts({
7  ids = null,
8  countryID,
9  RecommendedUse = null,
10  numbers = null,
11}) {
12  const BaseUrl = await getHostURL();
13  const url = new URL(`${BaseUrl}/v1.2/Parts`);
14
15  // ---- get token ----
16  const token = await getIdToken();
17
18  // ---- append query params ----
19  if (Array.isArray(ids)) {
20    ids.forEach((id) => url.searchParams.append('ids', id));
21  } else if (ids !== null) {
22    url.searchParams.append('ids', ids);
23  }
24
25  if (countryID) url.searchParams.append('countryID', countryID);
26  if (RecommendedUse !== null) url.searchParams.append('RecommendedUse', RecommendedUse);
27  if (Array.isArray(numbers)) {
28    numbers.forEach((number) => url.searchParams.append('numbers', number));
29  } else if (numbers !== null) {
30    url.searchParams.append('numbers', numbers);
31  }
32
33  const res = await fetch(url.toString(), {
34    method: 'GET',
35    headers: {
36      'Content-Type': 'application/json',
37      ...(token && { Authorization: `Bearer ${token}` }),
38    },
39  });
40
41  if (!res.ok) {
42    const err = await res.text();
43    buildErrorToast('Error', err.message || err);
44    throw new Error(err);
45  }
46
47  return res.json();
48}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.