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, { useState } from 'react'; | |
| function MyComponent() { | |
| const [firstName, setFirstName] = useState(''); | |
| const [lastName, setLastName] = useState(''); | |
| // This function is curried and it's a closure because it has access to the setFirstName and setLastName functions | |
| // which are defined in the parent scope | |
| const handleChange = (setter) => (event) => { | |
| setter(event.target.value); | |
| }; | |
| return ( |
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 from 'react'; | |
| const withNewProp = (WrappedComponent) => { | |
| const [count, setCount] = React.useState(0); | |
| return (props) => { | |
| return ( | |
| <WrappedComponent | |
| {...props} | |
| newProp='add many props' | |
| count={count} |
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
| HTTP | HTTPS | ||
|---|---|---|---|
| URL | http:// | https:// | |
| Security | Not secured | Secured with encryption | |
| Port | PORT 80 | PORT 443 | |
| OSI Layer | Application Layer | Transport Layer | |
| TLS Certificates | No | Yes | |
| Domain validation | Not required | Required | |
| Encryption | No | Yes |
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, {useEffect, useState} from 'react' | |
| import axios from 'axios' | |
| import logo from './logo.svg'; | |
| import './App.css'; | |
| function App() { | |
| const [message, setmessage] = useState("") | |
| const getData = async () => { | |
| const res = await axios.get('/profile') |
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 express = require("express"); | |
| const app = express(); | |
| const cors = require("cors"); | |
| const mongoose = require("mongoose") | |
| //importing the profile route | |
| const profileRoutes=require('./routers/profile') | |
| app.use(cors()); |
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
| //1 st step | |
| const express = require("express"); | |
| //2nd step | |
| const router = express.Router() | |
| //3rd step | |
| const profileController = require('../controllers/profile') | |
| //4th step |
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
| // newProfile function for post profile data | |
| const newProfile = (req, res, next) => { | |
| res.json({message: "Post new Profile"}); | |
| }; | |
| // newProfile function to get profile data | |
| const getProfile=(req,res,next)=>{ | |
| res.json({message: "get profile 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
| require("dotenv").config({ path: "./config.env" }); | |
| const port = process.env.PORT || 5001; | |
| mongoose | |
| .connect(process.env.ATLAS_URI, { | |
| useNewUrlParser: true, | |
| useUnifiedTopology: true, | |
| }) |
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 express = require("express"); | |
| const app = express(); | |
| const cors = require("cors"); | |
| const mongoose = require("mongoose") | |
| app.use(cors()); | |
| app.use(express.json()); | |
| require("dotenv").config({ path: "./config.env" }); | |
| const port = process.env.PORT || 5001; |
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 express = require("express"); | |
| const app = express(); | |
| const cors = require("cors"); | |
| const mongoose = require("mongoose") | |
| app.use(cors()); | |
| app.use(express.json()); |