小编iam*_*man的帖子

eslint解析错误:异常的意外令牌函数

我在节点js应用程序中使用eslint,但我在异步使用中出现以下错误.

eslint解析错误:异常的意外令牌函数

这是我的 eslintsrc

{
  "extends": "airbnb-base",
  "rules": {
    "no-console": "off",
    "func-style":"error",
    "import/no-extraneous-dependencies": ["error", {"devDependencies": false, "optionalDependencies": false, "peerDependencies": false, "packageDir": "./"}]
},
"parserOptions": {
  "ecmaVersion":8
 }
}
Run Code Online (Sandbox Code Playgroud)

UPDATE

这是我的异步

const get = async function get(req, res) {
  const user = await service.get();
  console.log("From db",user.username);
  res.send('ok');
};
Run Code Online (Sandbox Code Playgroud)

node.js eslint eslintrc

12
推荐指数
2
解决办法
6111
查看次数

引用错误onnotification未在推送通知cordova android中定义

使用Cordova(ionicframework + angularjs)构建以使用针对Android设备的推送通知请求.当进行注册时,successHandler()会触发('ok')消息结果!为什么onNotification()方法不会随时被触发?

var pushNotification;
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {

        pushNotification = window.plugins.pushNotification;
        setupNotificationsForandroid();
    }
   //begin setup
    function setupNotificationsForandroid() {
     //  alert("inside setup");
        if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){

            pushNotification.register(
            successHandler,
            errorHandler,
            {
                "senderID":"856763042820",
                "ecb":"onNotification"
            });
        } else {
            pushNotification.register(
            tokenHandler,
            errorHandler,
            {
                "badge":"true",
                "sound":"true",
                "alert":"true",
                "ecb":"onNotificationAPN"
            });
        }
    }
    function successHandler(result){

        //alert("success"+result);

    }
    function errorHandler(){

        alert("error");
    }
    // Android
    function onNotification(e) {
        //alert("inside onnotification");
        switch( e.event …
Run Code Online (Sandbox Code Playgroud)

javascript android push-notification cordova

11
推荐指数
1
解决办法
4197
查看次数

EKS:找不到任何合适的子网来创建 ELB

我正在尝试使用loadBalancer类型服务向外界公开服务。

为此,我遵循了这个文档

https://aws.amazon.com/premiumsupport/knowledge-center/eks-kubernetes-services-cluster/

我的loadbalancer.yaml看起来像这样

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: LoadBalancer
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
Run Code Online (Sandbox Code Playgroud)

但是负载平衡器没有按预期创建我收到以下错误

Warning  SyncLoadBalancerFailed  8s (x3 over 23s)  service-controller  Error syncing load balancer: failed to ensure load balancer: could not find any suitable subnets for creating the ELB
Run Code Online (Sandbox Code Playgroud)

似乎是因为子网标签中的一些问题需要解决,但我的子网中有所需的标签

kubernetes.io/cluster/<cluster-name>. owned  
kubernetes.io/role/elb   1
Run Code Online (Sandbox Code Playgroud)

但是,我仍然收到错误 could not find any suitable subnets for creating the ELB

amazon-web-services kubernetes aws-load-balancer amazon-eks

11
推荐指数
2
解决办法
1万
查看次数

Codeigniter:将单列中的所有值作为数组

这是我从t获取单个列的查询

$sql = "SELECT `id` FROM `loc8_groups`";
 $query = $this->db->query($sql);
 print_r($query>result());
Run Code Online (Sandbox Code Playgroud)

它的产生数组结果就像这样.

Array
(
    [0] => stdClass Object
        (
            [id] => 1
        )

    [1] => stdClass Object
        (
            [id] => 2
        )

    [2] => stdClass Object
        (
            [id] => 3
        )

)
Run Code Online (Sandbox Code Playgroud)

但我希望结果作为包含所有的单个关联数组ids.

php arrays codeigniter codeigniter-3

9
推荐指数
2
解决办法
1万
查看次数

JSON搜索laravel雄辩

我将destinations字段存储为json类型mysql

示例列值 ["Goa", "Moonar", "Kochi"]

我想获得匹配的所有行goa作为目的地

但是,此行查询返回所需的结果

SELECT * FROM `packages` 
WHERE JSON_CONTAINS(destinations, '["Goa"]');
Run Code Online (Sandbox Code Playgroud)

但是上述查询的雄辩等价是什么?

Laravel版本5.3

型号名称 :Search

php mysql laravel-5

8
推荐指数
2
解决办法
1万
查看次数

node.js 本地模块:找不到模块错误

我正在尝试在我的应用程序中实现本地模块

1.项目根文件夹我创建test 了一个名为的文件 夹index.js

      module.exports  = {

     myFunction:function(){
       console.log('ok');
     }
}
Run Code Online (Sandbox Code Playgroud)

2.package.json在根文件夹中添加以下内容

"dependencies": { 
    "test-module": "file:test"
  }
Run Code Online (Sandbox Code Playgroud)

3.当我尝试导入 var module = require('test-module');app.js出现此错误

找不到模块“测试模块”

javascript module node.js npm express

8
推荐指数
1
解决办法
1万
查看次数

在angularjs中将checked属性添加/删除到动态复选框

如何使用angularjs简单地添加和删除选中的属性到复选框.我从这个问题中找到了解决方案,但它需要Jquery

没有使用Jquery,还有其他方法吗?

这是我的尝试

<input type="checkbox" id="test"  class="switch__input" checked="{{checkVal}}">
<input type="button" ng-click="test()" value="test">
Run Code Online (Sandbox Code Playgroud)

JS

 module.controller('settingsCtrl',function($scope){
  //for adding
  $scope.checkVal="checked";
  //for removing checkbox
  $scope.test=function(){
   $scope.CheckVal="";
  }
}
Run Code Online (Sandbox Code Playgroud)

但删除不会工作

html javascript angularjs

7
推荐指数
1
解决办法
1万
查看次数

AWS cli:无权执行:sts:AssumeRole 对资源

我有一个 AWS 账户,我在其中承担了一个名为 A( role-A) 的角色,我从该角色role-B通过 Web 控制台创建了另一个名为 B( ) 的角色,并将管理员策略附加到该角色

这是cli配置

[default]
aws_access_key_id = <>
aws_secret_access_key = <>
region = eu-central-1

[role-B]
role_arn = arn:aws:iam::<id>:role/ics-role
mfa_serial = arn:aws:iam::<id>:mfa/<name>
external_id = <name>
source_profile = default
Run Code Online (Sandbox Code Playgroud)

role-B 我创建的 role-A

当我尝试获取角色详细信息时

aws --profile role-B sts get-caller-identity
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

调用 AssumeRole 操作时发生错误 (AccessDenied):用户:arn:aws:iam::<>:user/<> 无权执行:sts:AssumeRole 资源:arn:aws:iam::<>:角色/ics-角色

amazon-web-services amazon-iam aws-cli

7
推荐指数
1
解决办法
1万
查看次数

Jest 检测到以下 1 个打开的句柄可能会阻止 Jest 退出

这是我的 HTTP 路由

 app.get('/', (req, res) => {
    res.status(200).send('Hello World!')
})

app.post('/sample', (req, res) => {
    res.status(200).json({
        x:1,y:2
    });
})
Run Code Online (Sandbox Code Playgroud)

我想测试以下内容

1)GET要求工作正常。

2) /sample响应包含属性xy

const request = require('supertest');
const app = require('../app');

describe('Test the root path', () => {
    test('It should response the GET method', () => {
        return request(app).get('/').expect(200);
    });
})

describe('Test the post path', () => {
    test('It should response the POST method', (done) => {
        return request(app).post('/sample').expect(200).end(err,data=>{
            expect(data.body.x).toEqual('1');

        });
    });
}) …
Run Code Online (Sandbox Code Playgroud)

javascript testing express jestjs

6
推荐指数
3
解决办法
7990
查看次数

Angular 6:带有providIn的服务:“root”在组件中返回空对象

我的服务位于src/core/services/api.service.ts

\n\n
import { Injectable } from '@angular/core';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class ApiService {\n\n  constructor() { }\n\n  test() {\n    console.log('hello from services');\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在尝试从另一个模块中的组件调用此服务。

\n\n

home.component.ts

\n\n
import { Component, OnInit } from '@angular/core';\nimport {ApiService} from './core/services/api.service';\n\n@Component({\n  selector: 'app-home',\n  templateUrl: './home.component.html',\n  styleUrls: ['./home.component.css']\n})\nexport class HomeComponent implements OnInit {\n\n  constructor(private api: ApiService) { }\n\n  ngOnInit() {\n    console.log(this.api);\n  }\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

但我得到一个像这样的空对象ApiService\xc2\xa0{}

\n

javascript service dependency-injection angular

6
推荐指数
1
解决办法
1748
查看次数