@@ -42,9 +42,11 @@ export const partsHandlers = [
4242 return res ( ctx . status ( 200 ) , ctx . json ( applyPagination ( mockBmwAssets , pagination ) ) ) ;
4343 } ) ,
4444
45- rest . post ( `*${ environment . apiUrl } /assets/detail-information` , ( req , res , ctx ) => {
46- const { assetIds } = typeof req . body === 'string' ? JSON . parse ( req . body ) : req . body ;
47- return res ( ctx . status ( 200 ) , ctx . json ( assetIds . map ( id => getAssetById ( id ) ) ) ) ;
45+ rest . post ( `*${ environment . apiUrl } /assets/detail-information` , async ( req , res , ctx ) => {
46+ const { assetIds } = await req . json ( ) ;
47+
48+ const response = assetIds . map ( id => getAssetById ( id ) ) ;
49+ return res ( ctx . status ( 200 ) , ctx . json ( response . filter ( data => ! ! data ) ) ) ;
4850 } ) ,
4951
5052 rest . get ( `*${ environment . apiUrl } /assets/:partId` , ( req , res , ctx ) => {
@@ -56,7 +58,7 @@ export const partsHandlers = [
5658 rest . patch ( `*${ environment . apiUrl } /assets/:partId` , ( req , res , ctx ) => {
5759 const { partId } = req . params ;
5860 const currentPart = getAssetById ( partId as string ) ;
59- return res ( ctx . status ( 200 ) , ctx . json ( { ...currentPart , ...( req . body as Record < string , any > ) } ) ) ;
61+ return res ( ctx . status ( 200 ) , ctx . json ( { ...currentPart , ...req . json ( ) } ) ) ;
6062 } ) ,
6163
6264 rest . get ( `*${ environment . apiUrl } /assets/:assetId/children/:childId` , ( req , res , ctx ) => {
@@ -81,7 +83,9 @@ export const partsHandlersTest = [
8183
8284 rest . post ( `*${ environment . apiUrl } /assets/detail-information` , async ( req , res , ctx ) => {
8385 const { assetIds } = await req . json ( ) ;
84- return res ( ctx . status ( 200 ) , ctx . json ( assetIds . map ( id => mockAssetList [ id ] || getAssetById ( id ) ) ) ) ;
86+
87+ const response = assetIds . map ( id => mockAssetList [ id ] || getAssetById ( id ) ) ;
88+ return res ( ctx . status ( 200 ) , ctx . json ( response . filter ( data => ! ! data ) ) ) ;
8589 } ) ,
8690
8791 rest . get ( `*${ environment . apiUrl } /assets/:partId` , ( req , res , ctx ) => {
@@ -93,7 +97,7 @@ export const partsHandlersTest = [
9397 rest . patch ( `*${ environment . apiUrl } /assets/:partId` , ( req , res , ctx ) => {
9498 const { partId } = req . params ;
9599 const currentPart = mockAssetList [ partId as string ] ;
96- return res ( ctx . status ( 200 ) , ctx . json ( { ...currentPart , ...( req . body as Record < string , any > ) } ) ) ;
100+ return res ( ctx . status ( 200 ) , ctx . json ( { ...currentPart , ...req . json ( ) } ) ) ;
97101 } ) ,
98102
99103 rest . get ( `*${ environment . apiUrl } /assets/:assetId/children/:childId` , ( req , res , ctx ) => {
0 commit comments