mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-05-04 12:43:24 +00:00
Updated how Images are Handeled to Comply With Unsplash API Guidelines
This commit is contained in:
parent
d99f17c9d1
commit
01bebf0d83
3 changed files with 42 additions and 13 deletions
|
@ -34,15 +34,22 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
|
||||
const { title, image } = data;
|
||||
|
||||
const [imageId, imageThumbUrl, imageFullUrl, imageLinkHTML, imageUserName] =
|
||||
image.split('|');
|
||||
const [
|
||||
imageId,
|
||||
imageThumbUrl,
|
||||
imageFullUrl,
|
||||
imageLinkHTML,
|
||||
imageUserName,
|
||||
imageDownloadUrl,
|
||||
] = image.split('|');
|
||||
|
||||
if (
|
||||
!imageId ||
|
||||
!imageThumbUrl ||
|
||||
!imageFullUrl ||
|
||||
!imageUserName ||
|
||||
!imageLinkHTML
|
||||
!imageLinkHTML ||
|
||||
!imageDownloadUrl
|
||||
) {
|
||||
return {
|
||||
error: 'Missing fields. Failed to create board.',
|
||||
|
@ -52,6 +59,13 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
let board;
|
||||
|
||||
try {
|
||||
await fetch(imageDownloadUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Client-ID ${process.env.UNSPLASH_ACCESS_KEY}`,
|
||||
},
|
||||
});
|
||||
|
||||
board = await db.board.create({
|
||||
data: {
|
||||
title,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue