NodeJS environment variables in Grunt

use the grunt-env plugin: https://npmjs.org/package/grunt-env and set your config: grunt.initConfig({ env : { options : { //Shared Options Hash }, dev : { NODE_ENV : ‘development’, DEST : ‘temp’ } }, ‘another-task’: {} }); in your gruntfile you will probably define some default-task: grunt.registerTask(‘default’, [‘env’, ‘another-task’]); so if you run ‘grunt default’ at first your … Read more

Nodejs POST request multipart/form-data

After some more research, I decided to use the restler module. It makes the multipart upload really easy. fs.stat(“image.jpg”, function(err, stats) { restler.post(“http://posttestserver.com/post.php”, { multipart: true, data: { “folder_id”: “0”, “filename”: restler.file(“image.jpg”, null, stats.size, null, “image/jpg”) } }).on(“complete”, function(data) { console.log(data); }); });

Node.js async to sync

Use deasync – a module written in C++ which exposes Node.js event loop to JavaScript. The module also exposes a sleep function that blocks subsequent code but doesn’t block entire thread, nor incur busy wait. You can put the sleep function in your while loop: var asyncToSync = syncFunc(); function syncFunc() { var sync = … Read more

Can Gulp overwrite all src files?

I can think of two solutions: Add an option for base to your gulp.src like so: gulp.src([…files…], {base: ‘./’}).pipe(…)… This will tell gulp to preserve the entire relative path. Then pass ‘./’ into gulp.dest() to overwrite the original files. (Note: this is untested, you should make sure you have a backup in case it doesn’t … Read more

How to submit a form in Vue, redirect to a new route and pass the parameters?

The default behavior of <form> is to reload the page onsubmit. When implementing SPA’s it would be better to avoid invoking default behavior of <form>. Making use of router module which is available out-of-box in nuxtjs will enable all the redirection controls to flow within the application. if we try to trigger events available via … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)