feat: save query params in request, resolves #5

This commit is contained in:
Anoop M D 2022-10-02 03:27:55 +05:30
parent 2313afdb82
commit 8d4c56dbd9
2 changed files with 16 additions and 2 deletions

View File

@ -194,7 +194,7 @@ export const collectionsSlice = createSlice({
} }
}); });
// ultimately params get replaced with params in url + the disabled onces that existed prior // ultimately params get replaced with params in url + the disabled ones that existed prior
// the query params are the source of truth, the url in the queryurl input gets constructed using these params // the query params are the source of truth, the url in the queryurl input gets constructed using these params
// we however are also storing the full url (with params) in the url itself // we however are also storing the full url (with params) in the url itself
item.draft.request.params = concat(urlParams, disabledParams); item.draft.request.params = concat(urlParams, disabledParams);

View File

@ -100,6 +100,18 @@ export const transformCollectionToSaveToIdb = (collection, options = {}) => {
}); });
}; };
const copyQueryParams = (params) => {
return map(params, (param) => {
return {
uid: param.uid,
name: param.name,
value: param.value,
description: param.description,
enabled: param.enabled
}
});
};
const copyItems = (sourceItems, destItems) => { const copyItems = (sourceItems, destItems) => {
each(sourceItems, (si) => { each(sourceItems, (si) => {
const di = { const di = {
@ -116,6 +128,7 @@ export const transformCollectionToSaveToIdb = (collection, options = {}) => {
url: si.draft.request.url, url: si.draft.request.url,
method: si.draft.request.method, method: si.draft.request.method,
headers: copyHeaders(si.draft.request.headers), headers: copyHeaders(si.draft.request.headers),
params: copyQueryParams(si.draft.request.params),
body: { body: {
mode: si.draft.request.body.mode, mode: si.draft.request.body.mode,
content: replaceTabsWithSpaces(si.draft.request.body.content) content: replaceTabsWithSpaces(si.draft.request.body.content)
@ -128,6 +141,7 @@ export const transformCollectionToSaveToIdb = (collection, options = {}) => {
url: si.request.url, url: si.request.url,
method: si.request.method, method: si.request.method,
headers: copyHeaders(si.request.headers), headers: copyHeaders(si.request.headers),
params: copyQueryParams(si.request.params),
body: { body: {
mode: si.request.body.mode, mode: si.request.body.mode,
content: replaceTabsWithSpaces(si.request.body.content) content: replaceTabsWithSpaces(si.request.body.content)