Sails: about arrow function

Created on 19 Mar 2018  路  5Comments  路  Source: balderdashy/sails

Sails version:1.0
Node version:9.5.0
NPM version:5.6
DB adapter name: N/A
DB adapter version: N/A
Operating system:macOS High Sierra 10.13.1




customToJSON: function() {
// Return a shallow copy of this record with the password removed.
return _.omit(this, ['password'])
}

change to:

customToJSON: ()=> {
// Return a shallow copy of this record with the password removed.
return _.omit(this, ['password'])
}

didn't work

THKS

more info please question

All 5 comments

Hi @TxOne! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:

  • Verify "I am experiencing a concrete technical issue (aka a bug) with Sails (ideas and feature proposals should follow the guide for proposing features and enhancements (http://bit.ly/sails-feature-guide), which involves making a pull request). If you're not 100% certain whether it's a bug or not, that's okay--you may continue. The worst that can happen is that the issue will be closed and we'll point you in the right direction."
  • Verify "I am not asking a question about how to use Sails or about whether or not Sails has a certain feature (please refer to the documentation(http://sailsjs.com), or post on http://stackoverflow.com, our Google Group (http://bit.ly/sails-google-group) or our live chat (https://gitter.im/balderdashy/sails)."
  • Verify "I have already searched for related issues, and found none open (if you found a related _closed_ issue, please link to it in your post)."
  • Verify "My issue title is concise, on-topic and polite ("jst.js being removed from layout.ejs on lift" is good; "templates dont work" or "why is sails dumb" are not so good)."
  • Verify "I have tried all the following (if relevant) and my issue remains:"
  • Verify "I can provide steps to reproduce this issue that others can follow."

As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks!

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]

Hi @TxOne !
Any more details regarding your error ?
You can provide the the error log when you do sails lift.

Cheers !

@TxOne @Paskalouis

Arrow functions do not provide access to this, which is probably why the code above doesn't work

(would be cool at some point for some code in Sails core to run at lift-time and check each of the configured functions to provide better error messages about this...)

Hi @mikermcneil
Do you mean when sails lift, sails checking each controller if there is function written like this on this ?

EDIT:
I think the information is still vague. I tried on Sails v0.12.4 does not show any error.
Need more info regarding this from @TxOne.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Noitidart picture Noitidart  路  4Comments

visitsb picture visitsb  路  4Comments

randallmeeker picture randallmeeker  路  4Comments

Salakar picture Salakar  路  4Comments

3imed-jaberi picture 3imed-jaberi  路  3Comments