class Forest extends React.Component {
constructor(props) {
super(props)
this.plantRef = React.createRef()
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // src/middleware/errorHandler.js | |
| // Not found middleware | |
| // 404 | |
| const notFound = (req, res, next) => { | |
| const error = new Error(`Not Found - ${req.originalUrl}`); | |
| res.status(404); | |
| // pass error to the next middleware |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .Home { | |
| display: flex; | |
| min-height: 100vh; | |
| flex-direction: column; | |
| } | |
| .HomeContent { | |
| flex-grow: 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upload(files) { | |
| const config = { | |
| onUploadProgress: function(progressEvent) { | |
| var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
| console.log(percentCompleted) | |
| } | |
| } | |
| let data = new FormData() | |
| data.append('file', files[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // file: selected/dropped by user | |
| function displayImage(file) { | |
| const reader = new FileReader() | |
| reader.readAsDataURL(file) // reader.result will be `data:__` | |
| reader.onload = (e) => imageRef.current.src = reader.result | |
| console.log(reader.result) // returns `data:__` which is URL of files data | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "debug.javascript.codelens.npmScripts": "never", | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component, createRef } from "react"; | |
| class Input extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| name: "", | |
| copyMsg: "Copy to Clipboard", | |
| isCopied: false, | |
| }; |
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "allExampleCode" on type "Query".
If you don't expect "allExampleCode" to exist on the type "Query" it is most likely a typo.
However, if you expect "allExampleCode" to exist there are a couple of solutions to common problems:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Creating a passport strategy | |
| const JwtStrategy = require("passport-jwt").Strategy; | |
| const ExtractJwt = require("passport-jwt").ExtractJwt; | |
| const mongoose = require("mongoose"); | |
| // Get the user model | |
| const User = mongoose.model("users"); | |
| const keys = require("../config/keys"); | |
| const opts = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Validator = require("validator"); | |
| const isEmpty = require("./is-empty"); | |
| // we cant use isEmpty from validator pkg as it needs its param to be a string | |
| // data is req.body | |
| module.exports = function validateRegisterInput(data) { | |
| let errors = {}; | |
| data.name = isEmpty(data.name) ? "" : data.name; | |
| data.email = isEmpty(data.email) ? "" : data.email; |