Reputation: 21
a simple method is throwing me syntax error:
SyntaxError: Unexpected token .
module.exports.verifyStandardMetadata(data) => {
const result;
const json = JSON.parse(data);
if (json.status === '') {
json.status = 'Draft';
result = JSON.stringify(json);
return result;
}
};
Upvotes: 2
Views: 161
Reputation: 82096
Your export syntax is wrong - module.exports.verifyStandardMetadata(...)
would attempt to call a function, you want to set the function i.e.
module.exports.verifyStandardMetadata = data => {
....
}
Upvotes: 0
Reputation: 23029
the syntax must be a little different
module.exports.verifyStandardMetadata = (data) => {
const result;
const json = JSON.parse(data);
if (json.status === '') {
json.status = 'Draft';
result = JSON.stringify(json);
return result;
}
};
Also you have to change the result
from const
to let
as you are changing it
module.exports.verifyStandardMetadata = (data) => {
let result;
const json = JSON.parse(data);
if (json.status === '') {
json.status = 'Draft';
result = JSON.stringify(json);
return result;
}
};
Upvotes: 1