Reputation: 51
I am trying to implement push notification server with nodejs. I downloaded node-apn library and tried to initiate sample code. When I run sample code file, I got an error "unexpected syntax token ,". So I looked code line where syntax error occurs.
const Endpoint = require("./lib/protocol/endpoint")({
tls,
protocol,
});
This seems strange syntax but everybody else use node-apn library fine except me. I get syntax error if includes only one line of code below.
require("apn");
is there anyone who experienced this? or is there anybody who successfully implemented this node-apn library? any assistance will be appreciated. thanks in advance.
Upvotes: 2
Views: 202
Reputation: 211560
That's ES6 code for an object initializer and it's shorthand for:
const Endpoint = require("./lib/protocol/endpoint")({
tls: tls,
protocol: protocol,
});
If you're using an older version of Node, which comes with an older version of V8, you may have syntax errors.
Upvotes: 2