fix(core): update
This commit is contained in:
@ -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;
|
||||
|
@ -5,5 +5,5 @@ export interface ISmartRequestOptions extends https.RequestOptions {
|
||||
keepAlive?: boolean;
|
||||
requestBody?: any;
|
||||
autoJsonParse?: boolean;
|
||||
queryParams?: {[key: string]: string}
|
||||
queryParams?: { [key: string]: string };
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user