Proxy error: not proxy request /pizzas?



  • Boring. введите сюда описание изображения

    введите сюда описание изображения

    1. I'm bringing the wrong file.

    import axios from 'axios';
    

    export const setLoaded = (payload) => ({
    type: 'SET_LOADED',
    payload,
    });

    export const fetchPizzas = (sortBy, category) => (dispatch) => {
    dispatch({
    type: 'SET_LOADED',
    payload: false,
    });

    axios
    .get(
    /pizzas?${category !== null ? category=${category} : ''}&_sort=${sortBy.type}&_order=${ sortBy.order },
    )
    .then(({ data }) => {
    dispatch(setPizzas(data));
    });
    };

    export const setPizzas = (items) => ({
    type: 'SET_PIZZAS',
    payload: items,
    });

    Tell me how to make a mistake.

    1. Still making a mistake.

    введите сюда описание изображения

    Bringing the file package.json

    {
    "name": "react-pizza",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
    "@svgr/webpack": "4.3.3",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@typescript-eslint/eslint-plugin": "^2.10.0",
    "@typescript-eslint/parser": "^2.10.0",
    "babel-eslint": "10.1.0",
    "babel-jest": "^24.9.0",
    "babel-loader": "8.1.0",
    "babel-plugin-named-asset-import": "^0.3.6",
    "camelcase": "^5.3.1",
    "case-sensitive-paths-webpack-plugin": "2.3.0",
    "dotenv": "8.2.0",
    "dotenv-expand": "5.1.0",
    "eslint-config-react-app": "^5.2.1",
    "eslint-plugin-flowtype": "4.6.0",
    "eslint-plugin-import": "2.20.1",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-react": "7.19.0",
    "eslint-plugin-react-hooks": "^1.6.1",
    "fs-extra": "^8.1.0",
    "identity-obj-proxy": "3.0.0",
    "jest": "24.9.0",
    "jest-environment-jsdom-fourteen": "1.0.1",
    "jest-resolve": "24.9.0",
    "jest-watch-typeahead": "0.4.2",
    "pnp-webpack-plugin": "1.6.4",
    "postcss-loader": "3.0.0",
    "postcss-normalize": "8.0.1",
    "postcss-preset-env": "6.7.0",
    "prop-types": "^15.7.2",
    "react-app-polyfill": "^1.0.6",
    "resolve": "1.15.0",
    "semver": "6.3.0",
    "ts-pnp": "1.1.6",
    "webpack-manifest-plugin": "2.2.0",
    "json-server": "^0.16.1"
    },
    "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js",
    "server": "node server.js",
    "json-server": "json-server --watch public/db.json --port=3001"
    },
    "eslintConfig": {
    "extends": "react-app"
    },
    "proxy": "http://localhost:3001",
    "browserslist": {
    "production": [
    ">0.2%",
    "not dead",
    "not op_mini all"
    ],
    "development": [
    "last 1 chrome version",
    "last 1 firefox version",
    "last 1 safari version"
    ]
    },
    "jest": {
    "roots": [
    "<rootDir>/src"
    ],
    "collectCoverageFrom": [
    "src//*.{js,jsx,ts,tsx}",
    "!src/
    /.d.ts"
    ],
    "setupFiles": [
    "react-app-polyfill/jsdom"
    ],
    "setupFilesAfterEnv": [],
    "testMatch": [
    "<rootDir>/src//tests//
    .{js,jsx,ts,tsx}",
    "<rootDir>/src/**/.{spec,test}.{js,jsx,ts,tsx}"
    ],
    "testEnvironment": "jest-environment-jsdom-fourteen",
    "transform": {
    "^.+\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
    "^.+\.css$": "<rootDir>/config/jest/cssTransform.js",
    "^(?!.
    \.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
    "[/\]node_modules[/\].+\.(js|jsx|ts|tsx)$",
    "^.+\.module\.(css|sass|scss)$"
    ],
    "modulePaths": [],
    "moduleNameMapper": {
    "^react-native$": "react-native-web",
    "^.+\.module\.(css|sass|scss)$": "identity-obj-proxy"
    },
    "moduleFileExtensions": [
    "web.js",
    "js",
    "web.ts",
    "ts",
    "web.tsx",
    "tsx",
    "json",
    "web.jsx",
    "jsx",
    "node"
    ],
    "watchPlugins": [
    "jest-watch-typeahead/filename",
    "jest-watch-typeahead/testname"
    ]
    },
    "babel": {
    "presets": [
    "react-app"
    ]
    },
    "devDependencies": {
    "@babel/core": "^7.9.0",
    "axios": "^0.19.2",
    "babel-preset-react-app": "^9.1.2",
    "classnames": "^2.3.1",
    "css-loader": "^3.4.2",
    "eslint": "^6.8.0",
    "eslint-loader": "^3.0.3",
    "file-loader": "^4.3.0",
    "html-webpack-plugin": "^4.0.0-beta.11",
    "mini-css-extract-plugin": "^0.9.0",
    "node-sass": "^4.14.1",
    "optimize-css-assets-webpack-plugin": "^5.0.3",
    "postcss-flexbugs-fixes": "^4.1.0",
    "postcss-safe-parser": "^4.0.1",
    "react": "^16.14.0",
    "react-content-loader": "^5.1.4",
    "react-dev-utils": "^10.2.1",
    "react-dom": "^16.14.0",
    "react-redux": "^7.2.5",
    "react-router-dom": "^5.3.0",
    "redux": "^4.1.1",
    "redux-thunk": "^2.3.0",
    "resolve-url-loader": "^3.1.1",
    "sass-loader": "^8.0.2",
    "style-loader": "^0.23.1",
    "terser-webpack-plugin": "^2.3.5",
    "url-loader": "^2.3.0",
    "webpack": "^4.42.0",
    "webpack-dev-server": "^3.10.3",
    "workbox-webpack-plugin": "^4.3.1"
    }
    }

    Shouldn't we start servingr.js? If so, how do you do it?



  • You probably need to start a server. json-serverThe launch teams already exist, you can see them. package.json (Management) scripts) There is. server and can be launched: npm run server




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2