I am having an issue with an json bodyParser issue - body-parser

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
The bodyParser in VS Code has strikethroughs.
Rookie here! trying to get a Spotify clone to work. I've been trying to figure out what is going on here and how to fix it. Any insight is appreciated. Thank you!

Don't use bodyParser. It is deprecated, and that's why there are strikethroughs. Replace your lines with:
app.use(express.json());
app.use(express.urlencoded({extended: false});
I'm assuming you're using express. If not, just type
npm i express into your command line and then
const express = require('express');
at the top of your file.
or
npm i #types/express and import express from 'express' if you're using typescript

Related

Autocomplete django in visual studio code

hello everyone I am having a problem the visual studio code autocomplete for django does not work for me, because for python it does it without problems but when working with django the framework options do not work, that is when I work with views based on classes does not generate the autocomplete, such as template_name, form_class, etc ..., likewise with the models it does not generate the help of max_length, and those other things of the framework, I have selected the interpreter but it does not work for me and also python: build workspace symbols and nothing. in advance I appreciate the help.
You can install and activate python & Microsoft AI extension in visual studio code.
install some of the plugins for local and global
Global in vscode extensions:
Python (Microsoft)
Djaneiro
code spell checker
local:
pip install —dev autopep8 pep8 pylint pylint_django
Press CTRL+SHIFT+P(CMD+SHIFT+P for MacOS) -> ">select interpreter" -> select your virtual envirnoment
https://i.ibb.co/TTfkHRF/select-vir.gif
open vscode/setting.json file and past the beneath config code:
{
....
"editor.formatOnSave": true,
"python.formatting.provider": "autopep8",
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--load-plugin=pylint_django"
]
}

Angular 4 Unit Test cannot find name alert, confirm, event

Running ng test in angular-cli with Angular 4.0.0 gives errors like:
Cannot find name 'alert'
Cannot find name 'confirm'
Cannot find name 'Event'
This wasn't happening with Angular 2. Looks like something is missing here but what is it?
ng serve and build work fine.
In my case this was solved by adding "dom" to the "lib" array in tsconfig. I had a tsconfig.app.json that was used for building the app normally, and a tsconfig.spec.json that was just used for unit testing. This latter one was missing "dom".
{
"compilerOptions": {
...
"lib": [
"es2016",
"dom"
],
...
}
I was able to solve this by changing typings.d.ts according to latest cli documentation.
src/typings.d.ts:
Old:
/* SystemJS module definition */
declare var module: {
id: string;
};
New:
/* SystemJS module definition */
declare var module: NodeModule;
interface NodeModule {
id: string;
}
To fix the issue I have generated a new project using latest #angular/cli and then compared and updated all of my tsconfg files to the current format.

changing default download location in chrome using Pytest_mozwebqa

Can anyone please help how do i change the chrome settings in selenium using pytest to download files to a desired location.
what should i add to the below command in run configurations of eclipse to change the download path
--baseurl='http://example.com'--driver=chrome
In Python itself, it would be:
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option("prefs", {"download.default_directory": "some/path", "download.directory_upgrade": true})
driver = webdriver.Chrome(executable_path="the/path/to/the/driver.exe", chrome_options=chromeOptions)
Related: https://bugs.chromium.org/p/chromedriver/issues/detail?id=330
If I understand correctly how this "Pytest_mozwebqa" thingy works, you could try adding this command line:
--chromeopts='{"prefs":{"download.default_directory":"some/path","download.directory_upgrade":true}}'

HandlebarsHelper compiled templates tempateSpec.call undefined

I am having an issue with the HandlebarsHelper compiled templates on an MVC5 site. Here is the code for the BundleConfig:
bundles.Add(new Bundle("~/bundles/templates", new HandlebarsTransformer())
.IncludeDirectory("~/App/templates", "*.hbs", true));
This was working fine locally and then I pushed to a server hosting the QA environment and I was getting an assembly reference error saying the HandlebarsHelper plugin was calling Jurassic 2.1.0.0 and it wasn't found. So I added Jurassic through Nuget, since then the templates stopped working. I get this error from the browser:
Chrome:
Uncaught TypeError: undefined is not a function
Firefox:
TypeError: templateSpec.call is not a function
This is happening in the following section of handlebars.js:
return function(context, options) {
options = options || {};
var namespace = options.partial ? options : env,
helpers,
partials;
if (!options.partial) {
helpers = options.helpers;
partials = options.partials;
}
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
if (!options.partial) {
env.VM.checkRevision(container.compilerInfo);
}
return result;
};
I am running:
Ember 1.7.0
Ember-Data 1.0.0-beta.11
Handlebars 1.3.0
JQuery 2.1.1
MVC 5
.Net 4.5.2
I have been searching online all morning and not found any answers yet that have worked, I tried removing the Jurassic Nuget package and it did not help. Any ideas would be appreciated, let me know if there is any other info that would help diagnosing the issue.
You're on a version of HandlbarsHelper that's not supported for that version of Ember.js.
There was a breaking change for version 1.9 which added support for handlebars version 2.0. This is supported in HandlebarsHelper v2.0+. As a breaking change it means 2.0+ can't be used with Ember.JS < v1.9 and Handlebars < v2.0.
The reason why it was probably working initially was because in debug templates are usually just injected into the page unminified.
Easy fix is to use HandlebarsHelper v1.1 (https://www.nuget.org/packages/HandlebarsHelper/1.1.0)
The problem was I was using a version of Handlebars Helper that only supported handlebars 2.x. Found the issue in Nuget and changed it to a different version, everything works now. Thanks for the comments.

PHPUnit stoping with no feedback when trying to dispatch in Zend Framework controllers

[EDIT] My test enviroment is as seen in http://www.slideshare.net/DragonBe/unit-testing-after-zf-18 and using the source from https://github.com/DragonBe/zfunittest.
When I try to run a simples dispatch("/"), I´m getting the following as answer:
C:\wamp\www\MyProject\tests>phpunit
PHPUnit 3.7.19 by Sebastian Bergmann.
Configuration read from C:\wamp\www\MyProject\tests\phpunit.xml
.
C:\wamp\www\MyProject\tests>
Does anyone have a clue about what is happening?
The phpunit just stops and gives me no feedback.
I´m running Wampserver 2.2 over Windows 7x 64, ZF 1.11, PHP 5.4.3 and PHPunit 3.7.
Thank you all in advance.
In order to solve this problem, I tried to rewrite my files.
Removing ob_start() from the begining of my TestHelper.php, gave me the erros (thank God!), one after another, as I solved each of them (and phpunit was no more stoping execution):
Session must be started before any output has been sent to the
browser
No default module defined for this application
Fatal error: Call to a member function hasResource() on a non-object
in ...ErrorController.php
After some search in other posts, I tried the following, in the setUp method of my IndexControllerTest.php:
public function setUp(){
$this->bootstrap('session');
$front = Zend_Controller_Front::getInstance();
$front->setParam('noErrorHandler', true);
$this->getFrontController()->setControllerDirectory(APPLICATION_PATH . '/controllers');
parent::setUp();
}
Then, now this is working fine.
Thanks for all those who helped me.