mirror of
https://github.com/Lissy93/web-check.git
synced 2025-08-09 05:04:31 +02:00
Slight improvments to error messaging for sitemap and quality report
This commit is contained in:
@ -5,14 +5,17 @@ const handler = async (url, event, context) => {
|
||||
const apiKey = process.env.GOOGLE_CLOUD_API_KEY;
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error('API key (GOOGLE_CLOUD_API_KEY) not set');
|
||||
throw new Error(
|
||||
'Missing Google API. You need to set the `GOOGLE_CLOUD_API_KEY` environment variable'
|
||||
);
|
||||
}
|
||||
|
||||
const endpoint = `https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${encodeURIComponent(url)}&category=PERFORMANCE&category=ACCESSIBILITY&category=BEST_PRACTICES&category=SEO&category=PWA&strategy=mobile&key=${apiKey}`;
|
||||
const endpoint = `https://www.googleapis.com/pagespeedonline/v5/runPagespeed?`
|
||||
+ `url=${encodeURIComponent(url)}&category=PERFORMANCE&category=ACCESSIBILITY`
|
||||
+ `&category=BEST_PRACTICES&category=SEO&category=PWA&strategy=mobile`
|
||||
+ `&key=${apiKey}`;
|
||||
|
||||
const response = await axios.get(endpoint);
|
||||
|
||||
return response.data;
|
||||
return (await axios.get(endpoint)).data;
|
||||
};
|
||||
|
||||
module.exports = middleware(handler);
|
||||
|
Reference in New Issue
Block a user