This simple library exposes one function getTimezone
, which will take care
of everything the underlying API allows.
- have Node.js LTS with
npm
installed. Library enforces using Node.js version 20.x or higher, due to internal usage offetch
function.
import { getTimezone } from "worldtimeapi-lib";
const [data, status] = await getTimezone();
if (status) {
console.log(JSON.stringify(data));
}
const [data, status] = await getTimezone({ timezone: "Europe" });
const [data, status] = await getTimezone({ timezone: "Europe/Prague" });
import { getIpAddress } from "worldtimeapi-lib";
const [data, status] = await getIpAddress();
if (status) {
console.log(JSON.stringify(data));
}
const [data, status] = await getIpAddress({ ip: "8.8.8.8" });