mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
93468211d6
* chore: update eslint * chore: update rules and style * chore: aling formatting * chore: update ci rules * chore: aling formatting * chore: aling formatting
23 lines
632 B
TypeScript
23 lines
632 B
TypeScript
import { IncomingMessage } from 'http';
|
|
import request from 'request';
|
|
|
|
export function callRegistry(url: string): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
let options = {
|
|
url: url,
|
|
headers: { Accept: 'application/json' }
|
|
};
|
|
// @ts-ignore
|
|
request(options, (error: any, response: IncomingMessage, body: string) => {
|
|
if (error) {
|
|
reject(error);
|
|
// @ts-ignore
|
|
} else if (response.statusCode >= 400) {
|
|
reject(new Error(`Requesting "${url}" returned status code ${response.statusCode}.`));
|
|
} else {
|
|
resolve(body);
|
|
}
|
|
});
|
|
});
|
|
}
|