Commit 1494442d authored by Clark's avatar Clark
Browse files

reduce duplicate code

parent 4ab72c02
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ var _limitVal = 10;
 * @function callAPI
 * @description Fetches the STAC API at the collections level
 */
function callAPI() {
export function callAPI() {
  return fetch(
    "https://stac.astrogeology.usgs.gov/api/collections"
  ).then(response => response.json());
@@ -66,11 +66,6 @@ export function getItemCollection(name, queryString) {
  });
}

export function getCollectionNames(){
  return fetch(
    "https://stac.astrogeology.usgs.gov/api/collections"
  ).then(response => response.json());
}
/**
 * @function setFeatures
 * @description Sets the value of the max number of pages possible
+2 −2
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import "proj4leaflet";
import AstroProj from "./AstroProj";
import LayerCollection from "./LayerCollection";
import { getItemCollection,
         getCollectionNames,
         callAPI,
         setNumberMatched,
         setMaxNumberPages,
         getCurrentPage,
@@ -160,7 +160,7 @@ export default L.Map.AstroMap = L.Map.extend({
          }
        }
        var collectionNames ={};
        getCollectionNames().then(response =>{
        callAPI().then(response =>{
          for (let i = 0; i < response.collections.length; i++) {
            if (response.collections[i].hasOwnProperty("summaries")){
              if (