balderdashy / balderdashy/sails

Accessing helper gives error Cannot read property 'formatWelcomeMessage' of undefined

Open
#4,597 3 comments 0 reactions 0 assignees View on GitHub
inconsistency more info please
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Sails version**: 1.1.0
**Node version**: 10.15.0
**NPM version**: 6.4.1
**DB adapter name**: N/A
**DB adapter version**: N/A
**Operating system**: Windows 7



I was testing out helpers in my sails application and created a helper api/helpers/format-welcome-message.js with the exact code as in the [documentation](https://sailsjs.com/documentation/concepts/helpers). When I try to access the helper from my controller, I get an error "TypeError: Cannot read property 'formatWelcomeMessage' of undefined" when trying to invoke the helper from my controller. Given below is the controller code:

`try {
var greeting = await sails.helpers.formatWelcomeMessage('Bubba');
console.log(greeting);
} catch (error) {
console.log(error);
}

`

Contributor guide

Open the contributing guide

Research direction

Start with the helpers documentation and the reported file api/helpers/format-welcome-message.js, then compare its documented usage with the controller code that calls sails.helpers.formatWelcomeMessage('Bubba'). Reproduce the TypeError in the Sails 1.1.0 and Node 10.15.0 environment; done means the helper can be invoked from the controller without sails.helpers being undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.