H
Hono2w ago
Nicolas

Weird bug: JSON data not making it to server: RPC

Hi all, I am sending some data to my Hono server like so:
const places = await api.map.getPlaces.$post({
json: {
textQuery: "machine shop sheetmetal fabrication....",
lat: circle.snapshot.center.lat,
lng: circle.snapshot.center.lng,
radius: circle.snapshot.radius,
},
});
const places = await api.map.getPlaces.$post({
json: {
textQuery: "machine shop sheetmetal fabrication....",
lat: circle.snapshot.center.lat,
lng: circle.snapshot.center.lng,
radius: circle.snapshot.radius,
},
});
And getting the data on my server like so:
.post(
"/getPlaces",
zValidator("json", searchPlacesInput),
async (c) => {
const data = c.req.valid("json");
.post(
"/getPlaces",
zValidator("json", searchPlacesInput),
async (c) => {
const data = c.req.valid("json");
But apparently I am getting undefined for all the data, attached are screenshots of my network requests. Clearly it is getting data...., so i am not sure what to do or how to troubleshoot this. My intellisense is working fine and autocomplete works. Thanks!
No description
No description
2 Replies
Kaelwd
Kaelwd2w ago
Is c.req.json present if you remove the validator middleware?
Aditya Mathur
Aditya Mathur2w ago
Couple of things you can try - 1. Use something like Postman to send the POST request 2. Try removing the validator and checking the json body 3. Check your validation
Want results from more Discord servers?
Add your server