PageSourceSearch

https://explainly-ai.netlify.app/js/api.js

js explainly-ai.netlify.app collected 2026-10-03 10:43:08 UTC 1,169 bytes, 38 lines download raw bytes

1// Requires: config.js, auth.js loaded before this file
2
3function apiFetch(path, options) {
4  var opts = options || {};
5  var headers = Object.assign(
6    { 'Authorization': 'Bearer ' + getToken() },
7    opts.headers || {}
8  );
9
10  return fetch(BACKEND_URL + path, Object.assign({}, opts, { headers: headers }))
11    .then(function(r) {
12      if (r.status === 401) {
13        return refreshToken().then(function(newToken) {
14          headers['Authorization'] = 'Bearer ' + newToken;
15          return fetch(BACKEND_URL + path, Object.assign({}, opts, { headers: headers }));
16        });
17      }
18      return r;
19    })
20    .then(function(r) {
21      if (r.status === 204) return null;
22      if (!r.ok) throw new Error('API ' + r.status);
23      return r.json();
24    });
25}
26
27function fetchUsage() {
28  return apiFetch('/api/usage');
29}
30
31function fetchSaves(offset, limit) {
32  return apiFetch('/api/saves?offset=' + (offset || 0) + '&limit=' + (limit || 30))
33    .then(function(data) { return data && data.saves ? data.saves : (Array.isArray(data) ? data : []); });
34}
35
36function deleteSave(id) {
37  return apiFetch('/api/saves?id=' + encodeURIComponent(id), { method: 'DELETE' });
38}

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.