phanpy/scripts/fetch-instances-list.js
2024-02-17 16:49:50 +08:00

13 lines
331 B
JavaScript

import fs from 'fs';
const url = 'https://api.joinmastodon.org/servers';
const results = await fetch(url);
const json = await results.json();
const domains = json.map((instance) => instance.domain);
// Write to file
const path = './src/data/instances.json';
fs.writeFileSync(path, JSON.stringify(domains, null, '\t'), 'utf8');