Stop using request, replace it with already used axios

Changelog-entry: Stop using request, replace it with already used axios
Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-07-15 23:30:02 +02:00
parent e72049d6e8
commit dc9351713c
2 changed files with 3 additions and 6 deletions

View File

@ -14,17 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import axios from 'axios';
import * as Bluebird from 'bluebird'; import * as Bluebird from 'bluebird';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as request from 'request';
import * as tmp from 'tmp'; import * as tmp from 'tmp';
import { promisify } from 'util';
import * as errors from './errors'; import * as errors from './errors';
import * as settings from '../gui/app/models/settings'; import * as settings from '../gui/app/models/settings';
const getAsync = promisify(request.get);
export function isValidPercentage(percentage: any): boolean { export function isValidPercentage(percentage: any): boolean {
return _.every([_.isNumber(percentage), percentage >= 0, percentage <= 100]); return _.every([_.isNumber(percentage), percentage >= 0, percentage <= 100]);
} }
@ -55,7 +52,8 @@ export async function getConfig(): Promise<_.Dictionary<any>> {
const configUrl = const configUrl =
(await settings.get('configUrl')) || (await settings.get('configUrl')) ||
'https://balena.io/etcher/static/config.json'; 'https://balena.io/etcher/static/config.json';
return (await getAsync({ url: configUrl, json: true })).body; const response = await axios.get(configUrl, { responseType: 'json' });
return response.data;
} }
/** /**

View File

@ -96,7 +96,6 @@
"react-dom": "^16.8.5", "react-dom": "^16.8.5",
"redux": "^4.0.5", "redux": "^4.0.5",
"rendition": "^16.1.1", "rendition": "^16.1.1",
"request": "^2.81.0",
"resin-corvus": "^2.0.5", "resin-corvus": "^2.0.5",
"semver": "^7.3.2", "semver": "^7.3.2",
"simple-progress-webpack-plugin": "^1.1.2", "simple-progress-webpack-plugin": "^1.1.2",