Browse Source

feat: handle redirects in api definition request

pull/5137/head
Arman Ozak 6 years ago
parent
commit
19f272ca92
  1. 10
      npm/ng-packs/packages/schematics/src/utils/source.ts

10
npm/ng-packs/packages/schematics/src/utils/source.ts

@ -14,8 +14,14 @@ export async function getSourceJson(url: string) {
searchParams: { includeTypes: true },
https: { rejectUnauthorized: false },
}));
} catch (e) {
throw new SchematicsException(Exception.NoApi);
} catch (err) {
// handle redirects
try {
({ response: { body } } = err);
if (!body.types) throw Error('');
} catch (_) {
throw new SchematicsException(Exception.NoApi);
}
}
return body;

Loading…
Cancel
Save