I get this error msg ```[Typesense] Could not crea...
# community-help
d
I get this error msg
Copy code
[Typesense] Could not create document: ImportError: 913 documents imported successfully, 9 documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document.
I'm struggling how see the
error.importResults
(i.e. I'm doing it wrong haha). I'm doing something like this and none of the console logs in the catch prints what I'm after so I can debug and fix the documents that fail to import
Copy code
try {
    const res = await typesenseClient
      .collections(collection)
      .documents()
      .import(searchIndex, { action: 'upsert' });
  } catch (error) {
    console.log(error);
    console.log(error.importResults.filter((r) => r.success === false));
    error.importResults
      .filter((r) => r.success === false)
      .forEach((r) => {
        console.log(r);
      });
}
j
Could you console.log just error.importResults?
Instead of filtering it?
d
I hope I'm not that stupid that I never tried that. Not by my computer now but will report back my level of stupidity later
j
Haha, I was just curious what the exact server output was. My current suspicion is that true / false might be returned as strings instead of booleans which is why the filter might not be working as expected…
d
doing this worked 🤷
Copy code
} catch (error) {
  for (let i = 0; i < error.importResults.length; i++) {
    if (error.importResults[i].success === false) {
      console.log(`Error With Document: ${error.importResults[i].error}`);
    }
  }
}
🤔 1