Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
PayPal server integration does not pass data via the fetch body parameter

I'm following PayPal's server integration demo: https://developer.paypal.com/demo/checkout/#/pattern/server

The following code does not appear to be passing data via the "body" parameter:

      createOrder: function(data, actions) {
            return fetch('/paypal_api', {
                method: 'post',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({name:"sammy"}),
            }).then(function(res) {
                return res.json();
            }).then(function(orderData) {
                return orderData.id;
            });
        },

I am, however, able to pass parameters within the URL. For example:

return fetch('/paypal_api/<some_variable>/', {

So I can get this working but am bugged that the POST method does not appear to be working as expected. Here's a snippet from my python server code:

class createOrder(webapp2.RequestHandler): def get(self):

    print self.request.params

... and the print statement returns nothing (UnicodeMultiDict([])).

I'm 99% certain that I'm missing something obvious since google is not helping me! :)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Parse the request body as JSON

import json

jsonstring = self.request.body
jsonobject = json.loads(jsonstring)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda