我有一个 lambda 函数,它利用 Graphql 和 webscraping 返回一些数据作为响应。有时它不会出现像 502 这样的错误,有时它不会。对我来说,502 错误似乎是完全随机的,因为我一直使用相同的数据发送相同的请求。
我的超时在 AWS 控制台中设置为 5 分钟。
这些是我得到的错误(在浏览器中):
无法加载 [BIG URL] 请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问源 '[mydomainurl]'。响应具有 HTTP 状态代码 502。
spread.js:25 GET [大网址] 502 ()
但是,当我转到 Chrome 中的“网络”选项卡并在浏览器中查看复制的链接地址时,我会收到带有我想要的数据的 JSON 响应。我在 CloudWatch 中找不到错误。
标题
响应头
content-length: 36
content-type: application/json
date: Fri, 13 Apr 2018 06:17:06 GMT
status: 502
via: 1.1 67284fcf464f6f1529cc1e521669622c.cloudfront.net (CloudFront)
x-amz-apigw-id: FRC2oEiuDoEF_YQ=
x-amz-cf-id: O1VfzIVPySw657r6WV34EvcPMTyeT7eFUBnM3P30NXBmdjTeWHfryw==
x-amzn-requestid: 4766f279-3ee2-11e8-9e72-bdddab0f02d6
x-cache: Error from cloudfront
Run Code Online (Sandbox Code Playgroud)
请求头
:authority: wqbgu8c3ql.execute-api.eu-west-1.amazonaws.com
:method: GET
:scheme: https
accept: application/json, text/plain, */*
accept-encoding: gzip, deflate, br …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-lambda aws-api-gateway graphql-js serverless-framework
我正在使用 React-Datepicker 和 MomentJS。但是当我想使用 Moment 来设置 startDate 时,该值在 datepickerfield 中给出了无效日期。
当我在控制台中记录 this.state.startDate 时,控制台会显示以下内容:“startdate:27-11-2018”,格式为“DD-MM-YYYY”。此格式也用于 DatePicker 组件。
import * as React from "react";
import * as ReactDOM from "react-dom";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import * as moment from "moment";
import "moment/locale/nl";
export class DateContainer extends React.Component {
constructor(props) {
super(props);
this.state = {
startDate: moment().format('DD-MM-YYYY'),
};
}
render() {
console.log('startdate:',this.state.startDate);
return (
<div className="date-Filter">
<div className="date-Filter-Title">Release Date</div>
<DatePicker
onChange={this.handleStartDate}
selected={this.state.startDate}
dateFormat="DD-MM-YYYY"
isClearable={true}
placeholderText="Select a date other than today or yesterday" …Run Code Online (Sandbox Code Playgroud) 我正在使用 Webpack ^4.26.0。在用于 CSS 之前,我已经在 Webpack 3 中使用了“extract-text-webpack-plugin”。但是我已经读到该插件在 Webpack 4 上不再工作了。“extract-text-webpack-plugin”建议使用“mini-css-extract-plugin”插件。
我已经通过以下命令安装了插件:
npm install --save-dev mini-css-extract-plugin
并需要 webpackconfig 中的插件,还将其添加到我的规则和插件中:
// webpack.config.js
const webpack = require("webpack");
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const config = {
context: path.resolve(__dirname),
entry: "./index.js",
devServer: {
contentBase: "./dist"
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json"]
},
module: {
rules: [
{
test: …Run Code Online (Sandbox Code Playgroud) 我是GraphQL的新手。我正在使用Amazon和Itunes的API来获取书名(和其他信息)。我正在返回这样的对象:
var data = [];
data.title = results[0].title;
data.author = results[0].author;
return data;
Run Code Online (Sandbox Code Playgroud)
我可以调用Amazon和Itunes API并返回一本书的可用数据。但是,我希望能够插入EAN / ISBN数组,并从Amazon和Itunes返回所有书籍的数据。
因此查询将变成这样:
{
book(id:["9789025451608", "8974832789431","9789024576791"]){
amazon{
title
},
itunes{
title
}
}
}
Run Code Online (Sandbox Code Playgroud)
以及响应:
{
"data": {
"book": {
"book1":{
"amazon": {
"title": "De Moord op Commendatore"
},
"itunes": {
"title": "Niet beschikbaar" // not available
}
},
"book2":{
"amazon": {
"title": "Origin"
},
"itunes": {
"title": "Origin"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经搜索了使用graphQLList的示例,但是我不确定在哪里使用graphQLList以及如何遍历BookTypes。
也许有人可以帮助我或给我一个例子。
我的查询看起来像这样
{
book(id:["9789025451608"]){
amazon{
title
},
itunes{
title
} …Run Code Online (Sandbox Code Playgroud) 我想知道如何获得div的顶级父级.我知道你可以使用parent(),但我有多个div的点击功能
<div class="parent" data-row="1">
<div class="cat div1">
<div class="sub-cat div1_1">content</div>
<div class="sub-cat div1_2">content</div>
<div class="sub-cat div1_3">
<div class="inner-cat 1_3_3">innercontent</div>
</div>
</div>
<div class="cat div2">
<div class="sub-cat div2_1">content</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
假设我有一个父div,带有父类名,其中还包含一个索引号data-row.
我点击的功能.sub-cat,.inner-cat并且.cat,但是,我想要得到的data-row每点击功能.
我已经尝试通过使用$(this).closest('.parent')来获取父div来检索数据行,但这不起作用,因为它返回长度0.
当我的文件发生更改时,webpack-watch 会显示大量文本(下图的 3 倍)。这让我发疯,因为我只想查看已更改的文件或可能发生的错误。我经常忽略错误,因为文本太多。
是否可以仅显示错误,或仅显示真正更改的文件?如果是这样,我怎样才能实现这一目标?
这是我的配置:
// webpack.config.js
const webpack = require("webpack");
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const config = {
context: path.resolve(__dirname),
entry: "./index.js",
devServer: {
contentBase: "./dist",
stats: { chunks: false }
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json"]
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname),
use: [
{
loader: "babel-loader", …Run Code Online (Sandbox Code Playgroud) 我在引用 GraphQLObjectType 中的其他 GraphQLObjectType 时遇到了麻烦。我不断收到以下错误:
"message": "getBooks.stores 的类型必须是输出类型但得到:未定义。"
我认为在books.stores 中使用resolve 将有助于解决问题,但事实并非如此。有人可以帮我吗?
代码
var express = require('express');
var graphqlHTTP = require('express-graphql');
var graphql = require('graphql');
var { buildSchema, GraphQLSchema, GraphQLObjectType,GraphQLString,GraphQLList } = require('graphql');
var books = new GraphQLObjectType({
name:'getBooks',
fields: {
isbn: { type: GraphQLString},
stores: {
type: stores,
resolve: function(){
var store = [];
store.storeName = "this will contain the name of a shop";
return store;
}
}
}
});
var stores = new GraphQLObjectType({
name:'storeList',
fields: {
storeName: { …Run Code Online (Sandbox Code Playgroud) 我有以下理由。我调用网上商店的多个 API。每个网上商店都有自己的 GraphQLObjectType,如下面的代码所示。
我当前类型的代码:
// Amazon
const AmazonType = new GraphQLObjectType({
name: 'amazon',
fields: () => ( {
isbn: { type : GraphQLString},
title: { type: GraphQLString },
author: { type: GraphQLString},
publisher: { type: GraphQLString},
})
});
// itunes
const ItunesType = new GraphQLObjectType({
name: 'itunes',
fields: () => ( {
isbn: { type: GraphQLString },
title: { type: GraphQLString },
author: { type: GraphQLString },
publisher: { type: GraphQLString },
})
});
// query
const checkStores = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Elastic Search 5.6 中的主标题字段复制到另一个字段:index:false,因此我可以使用此字段来匹配确切的值。
然而。重新索引后,使用_source:["exact_hoofdtitel"]进行搜索,字段"exact_hoofdtitel"没有填充"hoofdtitel"的值。
PUT producten_prd_5_test
{
"aliases": {},
"mappings": {
"boek": {
"properties": {
"hoofdtitel": {
"type": "text",
"copy_to": [
"suggest-hoofdtitel", "exact_hoofdtitel"
]
},
"suggest-hoofdtitel": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": false,
"preserve_position_increments": true,
"max_input_length": 50
},
"exact_hoofdtitel":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"index":false
}
}
},
}
}
},
"settings": {
"number_of_shards": "1",
"number_of_replicas": "0"
}
}
GET producten_prd_5_test/_search
{
"_source":["hoofdtitel","exact_hoofdtitel"]
}
hits": [
{
"_index": "producten_prd_5_test",
"_type": "boek",
"_id": "9781138340671",
"_score": 1,
"_source": {
"hoofdtitel": "The …Run Code Online (Sandbox Code Playgroud) 我有一个char数组:
public static char[] boardposition = new char[9];
Run Code Online (Sandbox Code Playgroud)
我想重置数组,我的书面函数是:
public static void Reset()
{
Array.Clear(boardposition,9, boardposition.Length);
}
Run Code Online (Sandbox Code Playgroud)
当我打电话给Reset()我时,我得到一个类型的例外IndexOutOfRangeException.
我希望你们能帮助我.
graphql ×3
graphql-js ×3
arrays ×2
javascript ×2
webpack ×2
aws-lambda ×1
c# ×1
clear ×1
command-line ×1
config ×1
copy ×1
css ×1
datepicker ×1
html ×1
interface ×1
jquery ×1
list ×1
mapping ×1
module ×1
momentjs ×1
node.js ×1
object-type ×1
reactjs ×1