@carbonorm/carbonnode 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api/restRequest.ts +41 -26
package/package.json
CHANGED
package/src/api/restRequest.ts
CHANGED
|
@@ -366,7 +366,7 @@ export default function restApi<
|
|
|
366
366
|
C6,
|
|
367
367
|
axios = axiosInstance,
|
|
368
368
|
restURL = '/rest/',
|
|
369
|
-
|
|
369
|
+
withCredentials = true,
|
|
370
370
|
tableName,
|
|
371
371
|
requestMethod = GET,
|
|
372
372
|
queryCallback = {},
|
|
@@ -681,45 +681,60 @@ export default function restApi<
|
|
|
681
681
|
|
|
682
682
|
const axiosActiveRequest: AxiosPromise<ResponseDataType> = axios[requestMethod.toLowerCase()]<ResponseDataType>(
|
|
683
683
|
restRequestUri,
|
|
684
|
-
{
|
|
685
|
-
withCredentials: withCredentials,
|
|
686
|
-
...((() => {
|
|
684
|
+
...((() => {
|
|
687
685
|
|
|
688
|
-
|
|
686
|
+
// @link - https://axios-http.com/docs/instance
|
|
687
|
+
// How configuration vs data is passed is variable, use documentation above for reference
|
|
688
|
+
if (requestMethod === GET) {
|
|
689
689
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
} else if (requestMethod === POST) {
|
|
690
|
+
return [{
|
|
691
|
+
withCredentials: withCredentials,
|
|
692
|
+
params: query
|
|
693
|
+
}]
|
|
695
694
|
|
|
696
|
-
|
|
695
|
+
} else if (requestMethod === POST) {
|
|
697
696
|
|
|
698
|
-
|
|
699
|
-
convertForRequestBody<typeof data>(data, fullTableList, C6, (message) => toast.error(message, toastOptions)));
|
|
697
|
+
if (undefined !== request?.dataInsertMultipleRows) {
|
|
700
698
|
|
|
701
|
-
|
|
699
|
+
return [
|
|
700
|
+
request.dataInsertMultipleRows.map(data =>
|
|
701
|
+
convertForRequestBody<typeof data>(data, fullTableList, C6, (message) => toast.error(message, toastOptions))),
|
|
702
|
+
{
|
|
703
|
+
withCredentials: withCredentials,
|
|
704
|
+
}
|
|
705
|
+
]
|
|
702
706
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
} else if (requestMethod === PUT) {
|
|
707
|
+
}
|
|
706
708
|
|
|
707
|
-
|
|
709
|
+
return [
|
|
710
|
+
convertForRequestBody<RestTableInterfaces>(query as RestTableInterfaces, fullTableList, C6, (message) => toast.error(message, toastOptions)),
|
|
711
|
+
{
|
|
712
|
+
withCredentials: withCredentials,
|
|
713
|
+
}
|
|
714
|
+
]
|
|
708
715
|
|
|
709
|
-
|
|
716
|
+
} else if (requestMethod === PUT) {
|
|
710
717
|
|
|
711
|
-
|
|
712
|
-
|
|
718
|
+
return [
|
|
719
|
+
convertForRequestBody<RestTableInterfaces>(query as RestTableInterfaces, fullTableList, C6, (message) => toast.error(message, toastOptions)),
|
|
720
|
+
{
|
|
721
|
+
withCredentials: withCredentials,
|
|
713
722
|
}
|
|
723
|
+
]
|
|
724
|
+
} else if (requestMethod === DELETE) {
|
|
714
725
|
|
|
715
|
-
|
|
726
|
+
return [{
|
|
727
|
+
withCredentials: withCredentials,
|
|
728
|
+
data: convertForRequestBody<RestTableInterfaces>(query as RestTableInterfaces, fullTableList, C6, (message) => toast.error(message, toastOptions))
|
|
729
|
+
}]
|
|
716
730
|
|
|
717
|
-
|
|
731
|
+
} else {
|
|
718
732
|
|
|
719
|
-
|
|
733
|
+
throw new Error('The request method (' + requestMethod + ') was not recognized.')
|
|
720
734
|
|
|
721
|
-
}
|
|
722
|
-
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
})())
|
|
723
738
|
);
|
|
724
739
|
|
|
725
740
|
if (cachingConfirmed) {
|