小编roc*_*ter的帖子

moment().add()仅适用于文字值

我在TypeScript中使用Moment.js(如果重要的话,在Angular 2下).当我使用带有文字值的add()方法作为参数时,它工作正常:

moment().add(1, 'month');
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试用字符串替换单位,它将失败:

let units:string = 'month';
moment().add(1, units);
Run Code Online (Sandbox Code Playgroud)

有这个错误:

Argument of type '1' is not assignable to parameter of type 'DurationConstructor'.
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

momentjs typescript angular

18
推荐指数
3
解决办法
5257
查看次数

对受 IAP 保护的应用程序的服务帐户请求导致“GCIP ID 令牌无效:JWT 签名无效”

我正在尝试从 GCP 环境外部通过 Python 以编程方式访问受 IAP 保护的 App Engine Standard 应用程序。我尝试了各种方法,包括此处文档中显示的方法: https: //cloud.google.com/iap/docs/authentication-howto#iap-make-request-python。这是我的代码:

from google.auth.transport.requests import Request
from google.oauth2 import id_token
import requests

def make_iap_request(url, client_id, method='GET', **kwargs):
    """Makes a request to an application protected by Identity-Aware Proxy.

    Args:
      url: The Identity-Aware Proxy-protected URL to fetch.
      client_id: The client ID used by Identity-Aware Proxy.
      method: The request method to use
              ('GET', 'OPTIONS', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE')
      **kwargs: Any of the parameters defined for the request function:
                https://github.com/requests/requests/blob/master/requests/api.py
                If …
Run Code Online (Sandbox Code Playgroud)

google-app-engine google-api-python-client google-cloud-platform google-iap google-cloud-identity

4
推荐指数
1
解决办法
2104
查看次数