smallJSON gets random land

main
Keir Finlow-Bates 2 years ago
parent e4a616e71e
commit a2cd325b1a

@ -6,6 +6,7 @@
"start": "next start"
},
"dependencies": {
"axios": "^1.6.2",
"jimp": "^0.22.10",
"next": "latest",
"react": "18.2.0",

@ -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()
}
}
Loading…
Cancel
Save