Refactor getLocationOfTarget
This commit is contained in:
@ -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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user