Payload error in jsonwebtoken

It fails at the line const token = jwt.sign(user, config.secret, { With error “Expected “payload” to be a plain object” Your user object is initialized here: User.getUserByUsername(username, (err, user) Which I assume is mongoosejs object, which contains many methods and is not “serializable”. You could handle this by passing a plain object, by either using … Read more

What is the (ERR! code ENOLOCAL npm ERR!) Could not install because of an error?

This is an issue in node which is caused by white space in your windows username (possibly between the first-name and last-name in windows). run the following command after replacing firstname with your windows user firstname in command prompt with administrator access npm config set cache “C:\Users\Firstname~1\AppData\Roaming\npm-cache” –global

What is observable, observer and subscribe in angular?

Here is a simple visual to see the difference: As seen above … an Observable is a stream of events or data. They are often returned from Angular methods, such as the http.get and the myinputBox.valueChanges. Subscribing “kicks off” the observable stream. Without a subscribe (or an async pipe) the stream won’t start emitting values. … Read more

how to use underscore.js library in angular 2

For a project based on https://cli.angular.io, I needed to do the following: 1) Import libraries npm install underscore –save npm install @types/underscore –save 2) in tsconfig.app.json, add underscore to array ‘types’: “types”: [ “underscore” ] 3) In any component file I need to use underscore, I add this import * as _ from ‘underscore’; 4) … Read more

Angular Universal with i18n (Server Side Rendering)

A solution is to pre-build packages for each language, and have a proxy detect which bundle to serve as default. From the Angular docs on i8n: Merge with the AOT compiler The AOT (Ahead-of-Time) compiler is part of a build process that produces a small, fast, ready-to-run application package. When you internationalize with the AOT … Read more

Angular 6 library shared stylesheets

For global styles, I’ve answered it in this question. Update For ng-packgr versions 9.x and above Copying assest to output folder is now directly supported as explained in this page { “$schema”: “./node_modules/ng-packagr/package.schema.json”, “name”: “@my/library”, “version”: “1.0.0”, “ngPackage”: { “assets”: [ “CHANGELOG.md”, “./styles/**/*.theme.scss” ], “lib”: { … } } } So in your project you … Read more