diff --git a/server/api/collections.js b/server/api/collections.js index a516f34c..bdee2e3f 100644 --- a/server/api/collections.js +++ b/server/api/collections.js @@ -74,7 +74,10 @@ router.post("collections.create", auth(), async (ctx) => { ); } } else { - index = fractionalIndex(null, collections[0].index); + index = fractionalIndex( + null, + collections.length ? collections[0].index : null + ); } index = await removeIndexCollision(user.teamId, index); diff --git a/server/api/collections.test.js b/server/api/collections.test.js index a68be9bd..2a4c816f 100644 --- a/server/api/collections.test.js +++ b/server/api/collections.test.js @@ -1002,7 +1002,7 @@ describe("#collections.create", () => { }); it("should create collection", async () => { - const { user } = await seed(); + const user = await buildUser(); const res = await server.post("/api/collections.create", { body: { token: user.getJwtToken(), name: "Test" }, });