Refactor getLocationOfTarget

This commit is contained in:
2020-04-03 23:28:28 +08:00
parent ecaefb85bd
commit 86a27a2a81

View File

@ -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;
};