@@ -2,28 +2,12 @@ import { setProductsData } from '../redux/slices/mainSlice'
22import { store } from '../redux/store'
33
44export async function GetProductsService ( provider , apikey ) {
5- // const allProductRequests = ALL_PROVIDERS.map(async provider => {
6- // return fetch('/api/products', {
7- // headers: new Headers({
8- // 'Backend': provider.id,
9- // 'Authorization': `Bearer ${userToken}`
10- // })
11- // })
12- // .then(async res => await res.json())
13- // .then(data => { return { 'provider': provider.id, 'data': data } })
14- // });
15-
16- // Promise.all(allProductRequests).then((results) => {
17- // store.dispatch(setProductsData(Object.fromEntries(Object.values(results).map(value => {
18- // return value.data.products
19- // }))))
20- // }).catch(e => setError(e));
215
226 const PROVIDERS = [
237 { id : 'eusi' , url : 'https://apps.euspaceimaging.com/test/internal/stapi' }
248 ]
259
26- const allProductRequests = PROVIDERS_URLS . map ( async ( providerData ) => {
10+ const allProductRequests = PROVIDERS . map ( async ( providerData ) => {
2711 // Get all products meta data
2812 const productMetaResponse = await fetch ( providerData . url + '/products' , {
2913 method : 'GET'
@@ -55,33 +39,10 @@ export async function GetProductsService(provider, apikey) {
5539 } )
5640
5741 const results = await Promise . all ( allProductRequests )
42+ console . log ( 'products' , results [ 0 ] . productList )
43+ store . dispatch ( setProductsData ( results [ 0 ] . productList ) )
5844
59- // for (const url of baseurls) {
60- // // Get all products meta data
61- // const productMetaResponse = await fetch(url, { method: 'GET' }).then(
62- // (res) => res.json()
63- // )
64-
65- // // Get all constraints
66- // for (const product of productMetaResponse) {
67- // const constraints = await fetch(url + `/${product.id}/constraints`).then(
68- // (res) => res.json()
69- // )
70-
71- // const productParameters = await fetch(
72- // url + `/${product.id}/product-parameters`
73- // ).then((res) => res.json())
74-
75- // productList.push({
76- // ...product,
77- // constraints,
78- // productParameters
79- // })
80- // }
81- // }
82- console . log ( 'products' , results )
83-
84- const mockProducts = [
45+ /* const mockProducts = [
8546 {
8647 type: 'Product',
8748 conformsTo: ['https://geojson.org/schema/Polygon.json'],
@@ -261,8 +222,8 @@ export async function GetProductsService(provider, apikey) {
261222 // }
262223 // // }
263224 // // const EUSI_PRODUCTS = [EUSI_MAXAR_OPTICAL_PRODUCT]
264-
265- switch ( provider ) {
225+ */
226+ /* switch (provider) {
266227 case 'eusi':
267228 store.dispatch(setProductsData(eusiProducts))
268229 return
@@ -274,7 +235,6 @@ export async function GetProductsService(provider, apikey) {
274235 return
275236 default:
276237 console.error('Unsupported provider', provider)
277- }
238+ } */
278239
279- // store.dispatch(setProductsData(mockProducts))
280240}
0 commit comments