M
M
Markiv072021-02-12 23:00:35
Qiwi
Markiv07, 2021-02-12 23:00:35

Problem with redirect to Node.js Express JavaScript kiwi payment form?

Hello, here is such a problem, when you click the button, you need to redirect a person to the qiwi payment form (it seems to be created normally), such an error appears in the console. 6026de46a8c69030792260.png

Here is the code that I have in the main server script

app.get('/create-payment', function (req, res) {
  res.redirect(qiwi());
})
Qiwi is a payment form creation function

and here is the button click script
document.querySelectorAll('.payments').forEach(function(element){
  element.onclick = createPayment;
});

function createPayment() {
  fetch('/create-payment',
      {
          method: 'GET'
      }
  ).then(function (response) {
      return response.text();
  }
  )
}


What could be the problem? Help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Israfil22, 2021-02-12
@Markiv07

1 Error - https://expressjs.com/en/resources/middleware/cors.html . Documentation to help.
2 Error - You are redirecting to an AJAX request, not to the user's browser page.
Send a link to the redirect to him in json, for example.
When the answer comes, do a redirect from the browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question