smallJSON gets random land
parent
e4a616e71e
commit
a2cd325b1a
@ -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…
Reference in New Issue