Problem with pack.addSyncTable: The sync table does not populate with data

Hello everyone,

I’m trying to use pack.addSyncTable in a Coda Pack to create a sync table that fetches data from an external API. The idea is for the table to automatically update with data retrieved from the API.

However, when I try to sync the table in my Coda document, it does not populate with any data. It simply remains empty with the message: "No rows were returned during sync.

Here is the code I’m using:
import * as coda from “@codahq/packs-sdk”;
export const pack = coda.newPack();

pack.addNetworkDomain(“jsonplaceholder.typicode.com”);

pack.addSyncTable({
name: “Posts”,
description: “Syncs a list of posts from JSONPlaceholder.”,
identityName: “Post”,
schema: coda.makeObjectSchema({
properties: {
id: { type: coda.ValueType.Number, description: “Post ID” },
title: { type: coda.ValueType.String, description: “Post Title” },
body: { type: coda.ValueType.String, description: “Post Content” },
},
displayProperty: “title”,
idProperty: “id”,
}),
formula: {
name: “SyncPosts”,
description: “Fetches posts from JSONPlaceholder.”,
parameters: [
coda.makeParameter({
type: coda.ParameterType.Number,
name: “limit”,
description: “Number of posts to fetch. Default is 5.”,
optional: true,
}),
],
execute: async function ([limit = 3], context) {
let url = https://jsonplaceholder.typicode.com/posts?_limit=${limit};
let response = await context.fetcher.fetch({
method: “GET”,
url: url,
});

  // Returns the posts fetched from the API
  return response.body.map(post => ({
    id: post.id,
    title: post.title,
    body: post.body,
  }));
},

},
});

  1. The API works correctly:
    I tested the URL manually using tools like Postman and cURL, and it returns the expected data.
  2. Is this related to Coda’s plan limitations?
    Could it be that automatic table synchronization requires a paid plan?
  3. What might be wrong with the code?
    If there’s an issue with the schema, identityName, or the data being returned, I’d like to understand how to fix it.

Question:
• Why doesn’t the table populate when syncing?
• Is this related to Coda’s plan limitations, or is there something wrong with my code?
Thank you in advance for your help!


You should return an object with a result property, like this:

return {
  result: response.body.map...
};
1 Like

Yeah or just:

let rows = response.body.rows;
return {
  result: rows
}