Path: blob/master/src/packages/next/pages/api/v2/accounts/get-names.ts
1452 views
/*1Get first and last name for a list of account_id's.23The output is an object {names:{[account_id]:{first_name:string;last_name:string}}},4where the value for a given account_id is not given if that account does not5exist or was deleted (instead of an error).67There is about 30s of caching if you call this with the same input twice.8*/910import getAccountId from "lib/account/get-account";11import getParams from "lib/api/get-params";12import { getNames } from "@cocalc/server/accounts/get-name";1314export default async function handle(req, res) {15const account_id = await getAccountId(req);16if (account_id == null) {17res.json({ error: "must be signed in" });18return;19}2021let { account_ids } = getParams(req);2223try {24const names = await getNames(account_ids);25res.json({ names });26} catch (err) {27res.json({ error: `${err.message}` });28}29}303132