0

I need to implement 3rd party rest API in php project for integrating another project which is in angular.

Using rest API, I need to store cookie in the browser and cookie value will be in a specific format as instructed for which I need to import a specific npm package called angular2-cookie inside my root directory from

https://github.com/salemdar/angular2-cookie/blob/master/src/services/cookies.service.ts

I successfully installed it using npm command inside root directory.

In /js/sample-script.js

I imported the specific cookies.service.js file from that angular2-cookie module using browserify lib like

var CookieService = require('../node_modules/angular2-cookie/services/cookies.service');

var cs = new CookieService();
cs.putObject('somecookie',{user: 'john'});

but in the console, I am getting an error like:

Uncaught TypeError: CookieService is not a constructor

How can I implement putObject method from CookieService prototype?

Note: There is no error coming till 1st line where I used require method

6
  • Try this stackoverflow.com/questions/49063413/… Commented Oct 8, 2019 at 12:07
  • already tried like that Commented Oct 8, 2019 at 12:10
  • Okie, I'll to check on the same Commented Oct 8, 2019 at 12:12
  • @HiranyaSarma usage of the library is all documented in the README of the library, the code example you have given doesn't follow any of that. FWIW the library you are using is now deprecated. Commented Oct 8, 2019 at 12:15
  • can u little elaborate,what was not followed? Commented Oct 8, 2019 at 12:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.