Last active
January 3, 2016 20:19
-
-
Save mikermcneil/8513795 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Kasper (18c98c26@gateway/web/freenode/ip.24.201.140.38) has joined #sailsjs | |
<Kasper> Hi there! | |
<Kasper> Anyone got time for a question? | |
<robdubya> nothing but time Kasper | |
<Kasper> Wonderful! It's related to Services: How would I access the Sails config when writing a service? | |
* sailsTroll (~nodebot@ec2-54-209-111-37.compute-1.amazonaws.com) has joined #sailsjs | |
<robdubya> ha Kasper, how prescient of you | |
*/ | |
// api/services/FooService.js | |
module.exports = { | |
/** | |
* Some function that does stuff. | |
* | |
* @param {[type]} options [description] | |
* @param {Function} cb [description] | |
*/ | |
lookupDumbledore: function(options, cb) { | |
// `sails` object is available here: | |
var conf = sails.config; | |
cb(null, conf.whatever); | |
} | |
}; | |
// `sails` is not available here (it doesn't exist yet) |
Also see Create config variables in sails.js? for more details on other usage patterns.
In my routes.js
I am trying to set the page title within a route as per
'/index': {
view: 'home/index',
locals: {
title: sails.config.myApp + ' | The Home Page'
}
},
but it says ReferenceError: sails is not defined
How do I access configs within route definitions?
+1
+1
+1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this answers the question: