Merge pull request #2311 from makeplane/develop

promote: develop to stage release
This commit is contained in:
sriram veeraghanta 2023-09-29 18:07:14 +05:30 committed by GitHub
commit adf49782ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,19 +4,23 @@ import type { NextApiRequest, NextApiResponse } from "next";
const unsplashKey = process.env.UNSPLASH_ACCESS_KEY;
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { query, page, per_page = 20 } = req.query;
try {
const { query, page, per_page = 20 } = req.query;
const url = query
? `https://api.unsplash.com/search/photos/?client_id=${unsplashKey}&query=${query}&page=${page}&per_page=${per_page}`
: `https://api.unsplash.com/photos/?client_id=${unsplashKey}&page=${page}&per_page=${per_page}`;
const url = query
? `https://api.unsplash.com/search/photos/?client_id=${unsplashKey}&query=${query}&page=${page}&per_page=${per_page}`
: `https://api.unsplash.com/photos/?client_id=${unsplashKey}&page=${page}&per_page=${per_page}`;
const response = await axios({
method: "GET",
url,
headers: {
"Content-Type": "application/json",
},
});
const response = await axios({
method: "GET",
url,
headers: {
"Content-Type": "application/json",
},
});
res.status(200).json(response);
res.status(200).json(response?.data);
} catch (error) {
res.status(500).json({ message: "Failed to fetch unsplash", error });
}
}