第一次尝试 GraphQL,我希望一个架构类型能够访问另一个架构类型中的对象数组。在将其连接到 MongoDB 之前,我使用本地数据和 lodash 来测试它。关于我的尝试,我遇到了一些错误。我知道我已经很接近了。任何援助将不胜感激。
以下是我的最新尝试。我使用 express-graphql 访问 GraphQLList 并使用 GraphQLID 访问第二个架构。
架构.js
var projects = [
{
name: "Title 1",
subtitle: "Subtitle 1",
summary: "Lorem ipsum....",
languageId: ["4", "2"],
id: "1"
},
...
var languages = [
{ name: "Javascript", id: "1" },
{ name: "HTML", id: "2" },
{ name: "CSS", id: "3" },
{ name: "Python", id: "4" },
]
...
const ProjectType = new GraphQLObjectType({
name: 'Project',
fields: () => ({
id: { type: GraphQLID …Run Code Online (Sandbox Code Playgroud) 使用 React/Redux 前端和我自己的 nodejs/express api 开发登录表单/注销按钮。登录表单出现问题。大多数时候它工作得很好,但我经常遇到错误。第一个错误是forbidden,它告诉我用户在发送请求之前尚未完全通过身份验证userDetails。
还有另一个错误,Redux 不会更改用户的角色,我需要动态渲染导航。我认为将 handleLogin 转换为 async/await 将是解决方案,但我相信我做得不对。
import React from 'react';
import { login, userDetails } from '../axios/homeApi';
import { useForm } from 'react-hook-form';
import { useDispatch } from 'react-redux';
import { setLogin, setRole } from '../redux/actions';
const LoginForm = () => {
const { handleSubmit, register, errors } = useForm();
const dispatch = useDispatch();
const handleLogin = values => {
login(values.email, values.password)
.then(res => {
const token = res.data.token;
window.localStorage.setItem('auth', …Run Code Online (Sandbox Code Playgroud) I'm preparing for production on my first professional Django project, and I'm having issues with environment variables to secure the the application. So far I've managed to create a local file to store all variables on my pc...
env_variables.py
import os
db_user = os.environ.get('db_user')
db_password = os.environ.get('db_password')
# AWS DJANGO
export AWS_ACCESS_KEY_ID = "access_key"
export AWS_SECRET_ACCESS_KEY = "secret_key"
export AWS_STORAGE_BUCKET_NAME = "bucket_name"
print(db_user)
print(db_password)
Run Code Online (Sandbox Code Playgroud)
I've used the environment settings(windows) to create username and password. When I run the file they …
async-await ×1
django ×1
express ×1
graphiql ×1
graphql ×1
javascript ×1
lodash ×1
node.js ×1
python ×1
react-redux ×1