Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/api/attest/route.ts
Copy link

@MattWeinstein MattWeinstein Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs be a component, not just a function. If we want to display this link on the webpage it will need to be an anchor tag <a href=#></a> or use a component from a library next/link for example.

This way it will also be reusable.

Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ const getResponse = async (req: NextRequest): Promise<NextResponse> => {
}
}

const shareToTwitter = (attestation: string) => {
const tweet = encodeURIComponent(attestation);
const url = `https://twitter.com/intent/tweet?text=${tweet}`;
window.open(url, '_blank');
}

const attestationMessage = `Check out my attestation: ${JSON.stringify(data)}`;
shareToTwitter(attestationMessage);

export const POST = async(req: NextRequest): Promise<Response> => {
return getResponse(req);
}
Expand Down
9 changes: 9 additions & 0 deletions app/api/share/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ const getResponse = async (req: NextRequest): Promise<NextResponse> => {
)
}

const shareToTwitter = (attestation: string) => {
const tweet = encodeURIComponent(attestation);
const url = `https://twitter.com/intent/tweet?text=${tweet}`;
window.open(url, '_blank');
}

const attestationMessage = `Check out my attestation: ${JSON.stringify(data)}`;
shareToTwitter(attestationMessage);

export const POST = async(req: NextRequest): Promise<Response> => {
return getResponse(req);
}
Expand Down