INNER CODE UNIT · TypeScript

buildContext

hoowhoami/EchoMusic · src/main/external/index.ts:41

const buildContext = (): ProviderContext => ({
  fetchJson: async (url, headers) => {
    const res = await axios.get(url, {
      headers: headers ?? {},
      timeout: 15000,
      responseType: 'json',
      validateStatus: (s) => s >= 200 && s < 500,
    });
    if (res.status >= 400) {
      throw new Error(`远端返回 ${res.status}`);
    }
    return res.data;
  },
  fetchText: async (url, headers) => {
    const res = await axios.get(url, {
      headers: headers ?? {},
      timeout: 15000,
      responseType: 'text',

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…