V
V
Vann Damm2020-05-27 20:29:18
JavaScript
Vann Damm, 2020-05-27 20:29:18

Error when querying with Fetch?

The fetch request itself:

const request = useCallback(async (url, method = 'GET', body = null, headers = {}) => {
    setLoading(true)
    try {
      if (body) {
        body = JSON.stringify(body)
        headers['Content-Type'] = 'application/json'
      }

      const response = await fetch(url, {method, body, headers})
   /// КУСОК КОДА

BEC:
app.use(express.json({ extended: true }))
app.use('/reg',require('./routes/auth.route.js'));

ROUTER:
router.post(
  "/registration",
  async (req, res) => {
    try {
      const { mail, password } = req.body;
      const isUserWillBe = await User.findOne({ mail });
      if (isUserWillBe) {

// ТОЖЕ КУСОК КОДА,  тут всё понятно, до сюда даже не доходит всё валится на самом запросе.

I proxy requests from the front to the back, "proxy": " localhost:51984 " is registered in package.json. Instead of cors'a in the back.
Mistake:
5ecea36b4efd1623842221.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question