diff --git a/src/app.service.ts b/src/app.service.ts index 3a19ca9..3f3c895 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -11,10 +11,15 @@ const fetchTarget = async (target: string) => { export const getLocationOfTarget = async (target: string) => { try { - const { headers } = await fetchTarget(target); - return headers.location as string; + const response = await fetchTarget(target); + + if (response.headers.location) { + return response.headers.location as string; + } } catch (err) { - return undefined; + console.log(err); } + + return undefined; };