Universe API Wrapper using Node-Fetch
TIPS
To use Node-Fetch, you'll need to install Node.js
Node-Fetch requires Node v12.20.0 or higher.
npm install node-fetch
yarn add node-fetch
pnpm add node-fetch
const fetch = require("node-fetch"); const fetchData = async () => { try { const getResponse = await fetch("https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?", { method: "GET", headers: { Authorization: "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX", "Content-Type": "application/json" } }); const getData = await getResponse.json(); console.log(getData); } catch (error) { console.error("Error fetching data:", error); } }; fetchData();
import fetch from "node-fetch"; const fetchData = async () => { try { const getResponse = await fetch("https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?", { method: "GET", headers: { Authorization: "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX", "Content-Type": "application/json" } }); const getData = await getResponse.json(); console.log(getData); } catch (error) { console.error("Error fetching data:", error); } }; fetchData();
Last updated 10 months ago
Was this helpful?