Parcourir la source

Move api key to an environment variable.

Lee Morgan il y a 4 ans
Parent
commit
9c60841bbd
2 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 1 1
      controllers/gallery.js
  2. 2 2
      views/main/index.html

+ 1 - 1
controllers/gallery.js

@@ -59,7 +59,7 @@ module.exports = {
     getGalleries: function(req, res){
         Gallery.find()
             .then((galleries)=>{
-                return res.json(galleries);
+                return res.json({galleries: galleries, mapboxKey: process.env.MAPBOX_KEY});
             })
             .catch((err)=>{
                 return res.json("ERROR: could not fetch galleries");

+ 2 - 2
views/main/index.html

@@ -289,10 +289,10 @@
                 .catch((err)=>{});
 
             let loadGallery = (response)=>{
-                let galleries = response[1];
+                let galleries = response[1].galleries;
 
                 //MAP
-                mapboxgl.accessToken = 'pk.eyJ1IjoibGVlbW9yZ2FuaW8iLCJhIjoiY2tzYmtmcmxrMDdudjMxcXRrMnpxYXR4dCJ9.cyqsMBVBdoNVSQofam6djA';
+                mapboxgl.accessToken = response[1].mapboxKey;
                 let map = new mapboxgl.Map({
                     container: 'map',
                     style: 'mapbox://styles/mapbox/streets-v11',