#community-help

Resolving Issues with JSON Returns in Create() Calls

TLDR Krish was having trouble getting a JSON return from a create() call. Kishore Nallan and Jason suggested solutions but the issue was ultimately resolved by Krish finding a typo in their code.

Powered by Struct AI

1

1

16
10mo
Solved
Join the chat
Dec 14, 2022 (10 months ago)
Krish
Photo of md5-7dff5651efcba5c9cdfac93918dc7eeb
Krish
05:25 AM
Question: Is there a way to confirm if a create() (ie: index a single doc) call is successful? I was thinking it'll return something in json, but it doesn't.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
05:26 AM
201 status code
05:27
Kishore Nallan
05:27 AM
It does return the document back in JSON as well
Krish
Photo of md5-7dff5651efcba5c9cdfac93918dc7eeb
Krish
05:27 AM
i see it getting indexed but not getting the json
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
05:28 AM
What client are you using?
Krish
Photo of md5-7dff5651efcba5c9cdfac93918dc7eeb
Krish
05:30 AM
it's nodejs
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:22 AM
If there is an issue, I believe an exception is thrown.
Krish
Photo of md5-7dff5651efcba5c9cdfac93918dc7eeb
Krish
06:25 AM
Ideally I'd expect that. But I don't see anything returned. A curl invocation returns the record, but in node it doesn't. Let me play around for some time.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:26 AM
The node client returns a promise after async API calls, so you’d have to await the promise to get the API results
Krish
Photo of md5-7dff5651efcba5c9cdfac93918dc7eeb
Krish
06:40 AM
This is exactly how I coded it. When I didn't see the json I put it in a promise and I still don't see it :) I'll look for issues in code again..
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:48 PM
Hmm, could you share a minimal reproducible snippet I can run locally to replicate the issue?
Krish
Photo of md5-7dff5651efcba5c9cdfac93918dc7eeb
Krish
01:50 PM
Thank you Jason. But I fixed it. Sorry I wasted time here, it was a typo in my code.

1

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:51 PM
Phew, glad the issue is resolved!
Krish
Photo of md5-7dff5651efcba5c9cdfac93918dc7eeb
Krish
01:52 PM
Sorry man..
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:52 PM
No worries! Happy to help