mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
feat(license): use strapi.fetch method instead of fetch
This commit is contained in:
parent
2e95fd6eaf
commit
25c15f9ebf
@ -105,7 +105,9 @@ const onlineUpdate = async ({ strapi }) => {
|
||||
};
|
||||
|
||||
const license = shouldContactRegistry
|
||||
? await fetchLicense(ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(fallback)
|
||||
? await fetchLicense({ strapi }, ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(
|
||||
fallback
|
||||
)
|
||||
: storedInfo.license;
|
||||
|
||||
if (license) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
const crypto = require('crypto');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const machineId = require('../lib/utils/machine-id');
|
||||
|
||||
@ -69,12 +68,14 @@ const throwError = () => {
|
||||
throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);
|
||||
};
|
||||
|
||||
const fetchLicense = async (key, projectId) => {
|
||||
const response = await fetch(`https://license.strapi.io/api/licenses/validate`, {
|
||||
const fetchLicense = async ({ strapi }, key, projectId) => {
|
||||
const response = await strapi
|
||||
.fetch(`https://license.strapi.io/api/licenses/validate`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ key, projectId, deviceId: machineId() }),
|
||||
}).catch(throwError);
|
||||
})
|
||||
.catch(throwError);
|
||||
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user