diff --git a/package.json b/package.json index 80da52a..3b0fe9c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "start": "next start" }, "dependencies": { + "axios": "^1.6.2", "jimp": "^0.22.10", "next": "latest", "react": "18.2.0", diff --git a/pages/api/smallJSON.js b/pages/api/smallJSON.js new file mode 100644 index 0000000..11e77a1 --- /dev/null +++ b/pages/api/smallJSON.js @@ -0,0 +1,28 @@ +import axios from 'axios' +import { useRouter } from "next/router" + +export const config = { + api: { + externalResolver: true, + }, +} + +export default async function handler(req, res) { + const randCoords = "https://orthoverse.io/api/land/visit?name=random" + const jsonByCoords = "https://orthoverse.io/api/land/search/byCoordinates?" + + try { + axios.get(randCoords).then((loc) => { + axios.get(jsonByCoords + "x=" + loc.data.x + "&y=" + loc.data.y).then((result) => { + res.statusCode = 200 + res.json(result.data) + res.end() + }) + }) + } catch (err) { + // console.log(err) + res.status(404) + res.json({ error: "Something went wrong" }) + res.end() + } +}