Re-apply 'Migrate request to got (part 1)' (#6755)

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
chris48s
2021-07-11 14:28:14 +01:00
committed by GitHub
parent 5f9e8deafc
commit 8983c39f74
15 changed files with 492 additions and 132 deletions

View File

@@ -1,4 +1,5 @@
import Joi from 'joi'
import qs from 'qs'
import { nonNegativeInteger } from '../validators.js'
import { BaseJsonService, NotFound } from '../index.js'
@@ -49,29 +50,32 @@ export default class BaseWordpress extends BaseJsonService {
} else if (extensionType === 'theme') {
schemas = themeSchemas
}
const queryString = qs.stringify(
{
action: `${extensionType}_information`,
request: {
slug,
fields: {
active_installs: 1,
sections: 0,
homepage: 0,
tags: 0,
screenshot_url: 0,
downloaded: 1,
last_updated: 1,
requires_php: 1,
},
},
},
{ encode: false }
)
const json = await this._requestJson({
url,
schema: schemas,
options: {
qs: {
action: `${extensionType}_information`,
request: {
slug,
fields: {
active_installs: 1,
sections: 0,
homepage: 0,
tags: 0,
screenshot_url: 0,
downloaded: 1,
last_updated: 1,
requires_php: 1,
},
},
},
qsStringifyOptions: {
encode: false,
},
qs: queryString,
},
})
if ('error' in json) {