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
How I can insert a link in a Notion table? #119
Comments
URLs can be inserted without content, and without brackets, so just like this: Website: { url: req.body.website }, |
Unfortunately didn't work I have no idea why but I will just insert it all as text type. Thanks 🙏 |
@wahibAbdouWbs Did you got any example code write to Notion Database using Next.js or React? Thank you so much. |
I did develop a separated API backend from my front-end I'm not sure if it is possible to do that directly using notion-sdk-js. |
This is straight from my personal website: import { createPage, databasesId } from '@lib';
import { NextApiRequest, NextApiResponse } from 'next';
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const { Name, Email, Company, Content, Deadline, Brief } = req.body;
const newContact = await createPage({
parent: { database_id: databasesId.sections.contact },
properties: {
Name: {
title: [
{
text: {
content: Name,
},
},
],
},
Email: {
rich_text: [
{
text: {
content: Email,
},
},
],
},
Company: {
rich_text: [
{
text: {
content: Company,
},
},
],
},
Content: {
rich_text: [
{
text: {
content: Content,
},
},
],
},
Deadline: {
select: {
name: Deadline,
},
},
Brief: { url: Brief },
},
});
return res.status(200).json({
ok: true,
data: newContact,
});
} And the const notionBaseApi = 'https://api.notion.com/v1';
const fetchConfig: RequestInit = {
headers: {
Authorization: `Bearer ${process.env.NOTION_TOKEN}`,
'Notion-Version': '2021-05-13',
},
};
export const createPage = async (
args: WithAuth<PagesCreateParameters>
): Promise<PagesCreateParameters> => {
const res = await fetch(`${notionBaseApi}/pages`, {
...fetchConfig,
headers: {
...fetchConfig.headers,
'Content-Type': 'application/json',
},
method: 'post',
body: JSON.stringify(args),
});
const data = await res.json();
return data;
}; |
I tried to insert a text and a link into a Notion table it did work with the text but it didn't with the website link?
this is my express POST route any help?
Notion Table:
The text was updated successfully, but these errors were encountered: