这个错误来自哪里?我没有在任何地方使用ensureIndex或createIndex在我的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) 我正在尝试将本地图像导入 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) 我正在尝试学习 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。请帮助我理解这一点并修复此代码。
我已经成功安装了 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 运行时它开始运行。这令人沮丧,我不确定问题是什么。
我正在 reactjs 中开发一个管理应用程序,它使用 redux 进行状态管理。在我的应用程序中,当用户登录时,它会获取access_token和refresh _token. access_token5 分钟后过期。5 分钟后令牌变为无效,无法发出任何 api 端点请求。
我想知道我应该如何使用它refresh_token来更新我access_token存储在localStorage浏览器中的内容。在此refresh_token之前,我对此一无所知。这就是我提出登录请求并保存我的access_token和refresh_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) 我不知道这个问题是否有意义,但我对此感到非常困惑。我有一个帖子列表视图,它在此处呈现了一些帖子。
提出这种观点应该采取什么方法。
这是我的帖子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) 我正在开发一个需要从 api 获取数据并更改用户输入数据的应用程序。这里的问题是,当用户第一次安装页面时,他们应该发送默认值monthly和2020。但是,如果用户进行任何更改并且刷新页面,它应该向用户发送更新的数据。就像如果用户选择“半年”,然后2018刷新时它应该发送half-yearly和2018。我不确定在reacjs 中是否可行。
我尝试过这样做,但它不起作用monthly,2020每次刷新页面时它都会过去。
这是我的代码
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) > 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) 我正在尝试在我的颤振中实现一个时间选择器,它显示如下图所示的时间。
虽然我能够像这样格式化时间,但问题是它在小部件初始化时不显示当前时间。我试过用这个。在这里看到我的代码。
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) 我正在使用jest和testing-library/react编写单元测试。在此之前,我从未编写过任何单元测试。编写测试后,我收到类似这样的错误。
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) reactjs ×4
javascript ×2
node.js ×2
apexcharts ×1
bcrypt ×1
dart ×1
django ×1
flutter ×1
installation ×1
jestjs ×1
kotlin ×1
mongodb ×1
mongoose ×1
npm ×1
postgresql ×1
python ×1
random ×1
react-redux ×1
reactstrap ×1
widget ×1
window ×1
windows ×1