fix(core): update

This commit is contained in:
2022-02-15 18:57:42 +01:00
parent 92059a50de
commit d182832e47
8 changed files with 19 additions and 32 deletions

View File

@ -70,27 +70,28 @@ export const postFormData = async (
export const postFormDataUrlEncoded = async (
urlArg: string,
optionsArg: interfaces.ISmartRequestOptions = {},
payloadArg: {key: string, content: string}[]
payloadArg: { key: string; content: string }[]
) => {
const requestOptions = {
...optionsArg,
method: 'POST',
headers: {
...optionsArg.headers,
'content-type': 'application/x-www-form-urlencoded'
}
'content-type': 'application/x-www-form-urlencoded',
},
};
let resultString = '';
let resultString = '';
for (const keyContentPair of payloadArg) {
if (resultString) {
resultString += '&';
}
resultString += `${encodeURIComponent(keyContentPair.key)}=${encodeURIComponent(keyContentPair.content)}`;
resultString += `${encodeURIComponent(keyContentPair.key)}=${encodeURIComponent(
keyContentPair.content
)}`;
}
// lets fire the actual request for sending the formdata
const response = await request(urlArg + resultString, requestOptions);
return response;

View File

@ -5,5 +5,5 @@ export interface ISmartRequestOptions extends https.RequestOptions {
keepAlive?: boolean;
requestBody?: any;
autoJsonParse?: boolean;
queryParams?: {[key: string]: string}
queryParams?: { [key: string]: string };
}

View File

@ -104,7 +104,7 @@ export let request = async (
// parse url
const parsedUrl = plugins.smarturl.Smarturl.createFromUrl(urlArg, {
searchParams: optionsArg.queryParams || {}
searchParams: optionsArg.queryParams || {},
});
optionsArg.hostname = parsedUrl.hostname;
if (parsedUrl.port) {