小编adi*_*mar的帖子

(node:63208)不推荐使用DeprecationWarning:collection.ensureIndex.请改用createIndexes

这个错误来自哪里?我没有在任何地方使用ensureIndexcreateIndex在我的Nodejs应用程序中.我正在使用纱线包经理.

这是我的代码 index.js

import express from 'express';
import path from 'path';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import Promise from 'bluebird';

dotenv.config();
mongoose.Promise = Promise;
mongoose.connect('mongodb://localhost:27017/bookworm', { useNewUrlParser: true });

const app = express();
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

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

未找到模块:无法解析“../../assets/img-3.jpg”中的“../../assets/img-3.jpg”

我正在尝试将本地图像导入 reactjs。但它不起作用。我正在使用 reactstrap 制作旋转木马。

这是错误

找不到模块:无法解析“C:\Users\adity\Desktop\foodcubo-dev\project\src\Layouts\header”中的“../../assets/img-3.jpg”

我尝试使用导入方法导入图像,尽管图像在资产中可用。我想进口没问题。问题可能与渲染有关。我不知道。

这是我的代码。

头文件.js

import React, { Component } from 'react';
import imgone from '../../assets/img-1.jpg'
import imgtwo from '../../assets/img-2.jpg'
import imgthree from '../../assets/img-3.jpg'

import {
  Carousel,
  CarouselItem,
  CarouselIndicators,
  CarouselCaption
} from 'reactstrap';

const items = [
    {
    src: {imgone},
    altText: 'Slide 1',
    caption: 'Slide 1'
  },
    {
    src: {imgtwo},  
    altText: 'Slide 2',
    caption: 'Slide 2'
  },
    {
    src: {imgthree},
    altText: 'Slide 3',
    caption: 'Slide 3'
  }
];

class Header extends Component {
  constructor(props) {
    super(props); …
Run Code Online (Sandbox Code Playgroud)

reactjs reactstrap

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

无法创建抽象类的实例(随机)

我正在尝试学习 Kotlin,所以我正在学习互联网上的教程,其中讲师编写了一个与他们配合良好的代码,但它给我带来了错误。

这是错误

错误:(26, 17) Kotlin:无法创建抽象类的实例

import kotlin.random.Random

fun main(args: Array<String>) {
    feedTheFish()
}

fun feedTheFish() {
    val day = randomDay()
    val food = "pellets"
    print("Today is ${day} and the fish eat ${food}")
}


fun randomDay():String {
    val week = listOf ("Monday", "Tuesday", "wednesday", "thursday", "friday", "saturday", "sunday")
    return week[ Random().nextInt(7)]
}
Run Code Online (Sandbox Code Playgroud)

我从 return 语句中得到错误,我认为来自 Random。请帮助我理解这一点并修复此代码。

random kotlin

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

psql:错误:无法连接到服务器:致命:用户密码验证失败

我已经成功安装了 postgresql 并在 Windows 10 中添加了我的环境变量的路径。但问题是当我尝试psql postgresql在命令提示符下运行时,它给出了错误提示

C:\Users\adity>psql postgres
Password for user adity:
psql: error: could not connect to server: FATAL:  password authentication failed for user "adity"
Run Code Online (Sandbox Code Playgroud)

我 100% 确定我的密码是正确的我已经尝试重新安装和卸载很多次,以防我错过了密码,但每次都给我同样的错误。虽然当我尝试从 GUI 运行时它开始运行。这令人沮丧,我不确定问题是什么。

windows postgresql installation postgresql-9.5

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

如何在reactjs中使用刷新令牌

我正在 reactjs 中开发一个管理应用程序,它使用 redux 进行状态管理。在我的应用程序中,当用户登录时,它会获取access_tokenrefresh _token. access_token5 分钟后过期。5 分钟后令牌变为无效,无法发出任何 api 端点请求。

我想知道我应该如何使用它refresh_token来更新我access_token存储在localStorage浏览器中的内容。在此refresh_token之前,我对此一无所知。这就是我提出登录请求并保存我的access_tokenrefresh_token.

验证

export  const Authentication = async(payload) =>{
    try{
    const response = await fetch(`${generalConfig.baseURL}/oauth/token`, {
        method: 'POST',
        cache: 'no-cache',
        headers: {
            'Authorization': `Basic ${btoa("topseller:topseller")}`,
            'Accept': '*/*',
            // 'Content-Type': 'multipart/form-data',
            'accept-encoding': 'gzip, deflate',

        },
        body: payload
    })
    .then((response)=>{
        console.log(response)
        return response.json()
    },err=>{
       console.log(err,'############')
    })
    console.log(response,'@@@@@@@@@')
    return response;
}catch(err){
    console.log(err,'############')
}
}
Run Code Online (Sandbox Code Playgroud)

认证动作

export …
Run Code Online (Sandbox Code Playgroud)

authentication reactjs react-redux refresh-token

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

如何在Django的同一页面上拆分帖子视图

我不知道这个问题是否有意义,但我对此感到非常困惑。我有一个帖子列表视图,它在此处呈现了一些帖子。

我的问题是如何拆分页面的各个部分。 解释视图

提出这种观点应该采取什么方法。

这是我的帖子view.py

posts / view.py

class PostListView(ListView):
    model = Post
    template_name = 'posts/home.html'
    context_object_name = 'posts'
    ordering = ['-date_posted']

    def get_queryset(self):
        if not self.request.user.is_authenticated:
            return Post.objects.all()[:10]
        else : 
            return super().get_queryset()
Run Code Online (Sandbox Code Playgroud)

posts / models.py

from django.db import models
from django.utils import timezone
from slugger import AutoSlugField
from django.contrib.auth.models import User
from django.urls import reverse
# Create your models here.

def upload_location(instance, filename):
    return "%s/%s" %(instance.slug, filename)

class Category(models.Model):
    title = models.CharField(max_length= 60)
    slug = AutoSlugField(populate_from='title')
    parent = models.ForeignKey('self',blank=True, null=True …
Run Code Online (Sandbox Code Playgroud)

python django

5
推荐指数
1
解决办法
180
查看次数

如何在react js中将数据搜索参数保留在url中

我正在开发一个需要从 api 获取数据并更改用户输入数据的应用程序。这里的问题是,当用户第一次安装页面时,他们应该发送默认值monthly2020。但是,如果用户进行任何更改并且刷新页面,它应该向用户发送更新的数据。就像如果用户选择“半年”,然后2018刷新时它应该发送half-yearly2018。我不确定在reacjs 中是否可行。

我尝试过这样做,但它不起作用monthly2020每次刷新页面时它都会过去。

这是我的代码

const DispensingIncidents = (props) => {
  const classes = useStyles();
  const {
    getFilterData,
    dispensingData,
    getPeriodList,
    getOverviewData,
    location,
    history,
  } = props;

  const [timeSpan, setTimeSpan] = React.useState("Monthly");
  const [year, setYear] = React.useState(2020);
  const [tabValue, setTabValue] = React.useState(0);
  const [spanData, setSpanData] = React.useState([]);
  const { loading, duration, period, dispensingOverviewData } = dispensingData;
  const { count } = dispensingOverviewData;

  useEffect(() => {
    getPeriodList(); …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

5
推荐指数
1
解决办法
2264
查看次数

在nodejs中安装bycrpt时出错?每当我运行 npm install install --save?

> bcrypt@3.0.0 install C:\projects\alecadApi\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

`node-pre-gyp` WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.0/bcrypt_lib-v3.0.0-node-v57-win32-x64-unknown.tar.gz
`node-pre-gyp` WARN Pre-built binaries not found for bcrypt@3.0.0 and node@8.10.0 (node-v57 ABI, unknown) (falling back to source compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
`C:\projects\alecadApi\node_modules\bcrypt\build\bcrypt_lib.vcxproj(20,3)`: error MSB4019: The imported project "C:\Microsoft.Cp
p.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on …
Run Code Online (Sandbox Code Playgroud)

window bcrypt node.js npm

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

如何在timePicker中格式化时间

我正在尝试在我的颤振中实现一个时间选择器,它显示如下图所示的时间。

格式化时间

虽然我能够像这样格式化时间,但问题是它在小部件初始化时不显示当前时间。我试过用这个。在这里看到我的代码。

TimeOfDay _currentTime = new TimeOfDay.now();

String timeText = 'Set A Time';
Future<Null> selectTime(BuildContext context) async {
      TimeOfDay selectedTime = await showTimePicker(
        context: context,
        initialTime: _currentTime,
      );

      MaterialLocalizations localizations = MaterialLocalizations.of(context);
      String formattedTime = localizations.formatTimeOfDay(selectedTime,
          alwaysUse24HourFormat: false);

      if (formattedTime != null) {
        setState(() {
          timeText = formattedTime;
        });
      }
    };
Run Code Online (Sandbox Code Playgroud)

小部件日期选择器

class DatePicker extends StatelessWidget {
  DatePicker({
    this.formatedDate,
    this.selectedDate,
  });

  final String formatedDate;
  final Function selectedDate;

  @override
  Widget build(BuildContext context) {
    return FlatButton(
      padding: EdgeInsets.only(top: 30.0, bottom: 10.0),
      child: …
Run Code Online (Sandbox Code Playgroud)

widget dart flutter

3
推荐指数
1
解决办法
4832
查看次数

TypeError: r.node.getBBox 不是函数”。] { code: 'ERR_UNHANDLED_REJECTION' }

我正在使用jesttesting-library/react编写单元测试。在此之前,我从未编写过任何单元测试。编写测试后,我收到类似这样的错误。

\n
 FAIL  src/__test__/components/Barchart.test.tsx\n  \xe2\x97\x8f Test suite failed to run\n\n    Call retries were exceeded\n\n      at ChildProcessWorker.initialize (node_modules/jest-worker/build/workers/ChildProcessWorker.js:193:21)\n\nnode:internal/process/promises:245\n          triggerUncaughtException(err, true /* fromPromise */);\n          ^\n\n[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: r.node.getBBox is not a function".] {\n  code: 'ERR_UNHANDLED_REJECTION'\n}\nnode:internal/process/promises:245\n          triggerUncaughtException(err, true /* fromPromise */);\n          ^\n\n[UnhandledPromiseRejection: This error originated either by throwing …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs jestjs react-testing-library apexcharts

3
推荐指数
1
解决办法
2219
查看次数