-1

Following code is throwing a syntax error in node v10.15.3

var lti = require('library name');

var provider = lti.somemethod(some arguments)
// following line throw syntax error
provider.valid_request req, (err, isValid) ->
Punit
  • 31
  • 2
  • 1
    if you want to use to `arrow function` its `(arg1, arg2) => { //code block }` https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions – 1565986223 Mar 30 '19 at 07:04
  • `->` is not part of any old or new JavaScript syntax, it's [CoffeeScript](https://coffeescript.org/#introduction). – TGrif Mar 30 '19 at 10:30

1 Answers1

0

Normal Javascript Syntax

function myFunc(arg1, arg2, arg3){
    // Func logic here
}

This function can be rewritten in ES6 syntax as following

const myFunc = (arg1, arg2, arg3) => {
    // Func Logic Here
}

I Assume that in your question, provider.valid_request is a function which takes in a callback function as an argument.

so you can write it as

provider.valid_request(req, (err, isValid) => {
    if(!err && isValid){
      // logic here
    }
})
Shekar Mania
  • 307
  • 3
  • 7