-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type checking issue when querying a database: properties field #527
Comments
When querying database using a filter, I receive a "body failed validation" error APIResponseError: body failed validation. Fix one:
body.filter.or should be defined, instead was `undefined`.
body.filter.and should be defined, instead was `undefined`.
body.filter.title should be defined, instead was `undefined`.
body.filter.rich_text should be defined, instead was `undefined`.
body.filter.number should be defined, instead was `undefined`.
body.filter.checkbox should be defined, instead was `undefined`.
body.filter.select should be defined, instead was `undefined`.
body.filter.multi_select should be defined, instead was `undefined`.
body.filter.status should be defined, instead was `undefined`.
body.filter.date should be defined, instead was `undefined`.
body.filter.people should be defined, instead was `undefined`.
body.filter.files should be defined, instead was `undefined`.
body.filter.url should be defined, instead was `undefined`.
body.filter.email should be defined, instead was `undefined`.
body.filter.phone_number should be defined, instead was `undefined`.
body.filter.relation should be defined, instead was `undefined`.
body.filter.created_by should be defined, instead was `undefined`.
body.filter.created_time should be defined, instead was `undefined`.
body.filter.last_edited_by should be defined, instead was `undefined`.
body.filter.last_edited_time should be defined, instead was `undefined`.
body.filter.formula should be defined, instead was `undefined`.
body.filter.unique_id should be defined, instead was `undefined`.
body.filter.rollup should be defined, instead was `undefined`.
at async ProjectsList (./src/app/components/ProjectsList.tsx:23:35)
digest: "716658379" const { results } = await notion.databases.query({
database_id: databaseId!,
filter: {
property: "Tags",
contains: "AI",
}
});
console.log(results); Below is the response when querying the database; you can see properties exist. [
{
object: 'page',
id: '039c4ca9-e237-481a-9581-',
created_time: '2024-10-01T20:21:00.000Z',
last_edited_time: '2024-10-05T00:35:00.000Z',
created_by: { object: 'user', id: 'f65771fb-5ea1-4e48-b963-' },
last_edited_by: { object: 'user', id: 'f65771fb-5ea1-4e48-b963-' },
cover: null,
icon: null,
parent: {
type: 'database_id',
database_id: '112794ea-af04-8071-8225-'
},
archived: false,
in_trash: false,
properties: {
'Current Versions': [Object],
'Github Repos': [Object],
Directory: [Object],
'Main Run Command': [Object],
'Short Description': [Object],
Tags: [Object],
Name: [Object]
},
url: 'https://www.notion.so/....',
public_url: null
}
] Node version: 20.17.0 I also have typescript issues when trying to access the custom properties. It seems like the typescript definitions are not accurate when it comes to properties. |
See section Type Guards from the README. These narrow types for the use case you show. TypeScript Playground with an example of safely reading |
Report bugs here only for the Node JavaScript library.
If you're having problems using Notion's API, or have any other feedback about the API including feature requests for the JavaScript library, please email support at [email protected].
Describe the bug
When querying a database the response types are suggesting that 'properties' does not exist on 'PartialPageObjectResponse'
Below is the response when querying the database; you can see properties exist.
Is there a way to handle this, instead of me manually defining the response which seems unnecessary.
To Reproduce
Node version:
Notion JS library version:
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Please include any screenshots that help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: