The comments namespace of @getenginex/sdk-predictions covers each market's comments. Reading is public; commenting, liking and listing your own requires login (without a session, the method rejects with UNAUTHENTICATED before any request).
Returns { items, total } (not a Page): total is the market's total number of comments, for computing pages. Pagination uses limit/offset; the gateway defaults to 50. Root comments carry their replies in replies.
ts
let offset = 0const all = []while (true) { const { items, total } = await predictions.comments.list({ marketId, limit: 50, offset }) all.push(...items) offset += items.length if (items.length === 0 || offset >= total) break}
A comment (Comment) carries parentId ('' for a root), depth (0 root, 1 reply, 2 reply to a reply; the maximum is 2), likesCount, repliesCount, likedByMe and status: pending (under moderation), approved or rejected (with rejectionReason). A status the SDK doesn't know follows the rule for unknown enums.
withPredictionsRoutes() seeds two comments in mock-market-1 and keeps the state in memory per mock: create (root or reply, up to depth 2), like/unlike (one like per user) and list your own. The routes that require a session answer 401 without a token, so log in (enginex.auth.login, any email and password in the mock) first.
Comments
The
commentsnamespace of@getenginex/sdk-predictionscovers each market's comments. Reading is public; commenting, liking and listing your own requires login (without a session, the method rejects withUNAUTHENTICATEDbefore any request).List
Returns
{ items, total }(not aPage):totalis the market's total number of comments, for computing pages. Pagination useslimit/offset; the gateway defaults to 50. Root comments carry their replies inreplies.A comment (
Comment) carriesparentId(''for a root),depth(0 root, 1 reply, 2 reply to a reply; the maximum is 2),likesCount,repliesCount,likedByMeandstatus:pending(under moderation),approvedorrejected(withrejectionReason). Astatusthe SDK doesn't know follows the rule for unknown enums.Comment, reply and like
createdoes not sendIdempotency-Key: repeating the call (e.g. a double click) posts again. Disable the button while the call is in progress.contentis not validated in the SDK: the gateway answersINVALID_ARGUMENT, which arrives as anEnginexError.like,unlikeandcreatereturn the comment (HTTP 200,createincluded).COMMENT_NOT_FOUNDandMARKET_NOT_FOUNDarrive with HTTP 500: decide bycode(isEnginexError(error, 'COMMENT_NOT_FOUND')).Testing
withPredictionsRoutes()seeds two comments inmock-market-1and keeps the state in memory per mock: create (root or reply, up to depth 2), like/unlike (one like per user) and list your own. The routes that require a session answer401without a token, so log in (enginex.auth.login, any email and password in the mock) first.