#Empress Brosephine-create-customer

1 messages · Page 1 of 1 (latest)

cerulean viper
#

Hello 👋
can you log data and share what the object looks like?

coarse tapir
#

Hey Hanzo!

cid: [object Response] RegistrationForm.js:74

cerulean viper
#

are you correctly parsing the response coming from your server?

#

It doesn't look like a plain old javascript object

coarse tapir
#

I think so? This is what I have:

app.post('/create-customer', async(req,res,next)=>{
  try{
    const customer = await stripe.customers.create({
      email: req.query.email,
      name: req.query.name
    }).then((data)=>{
      res.status(200).send({
        customerId: data
      })
    })
  }catch(e){
    res.status(401).send({error: e})
  }
})
#

sorry, i've been bashing my head in against this Stripe Cypress tester for like 3 days now so silly mistakes are happening lol

fair fossil
#
      email: req.query.email,
      name: req.query.name
    });
const customerId = customer.id;```
coarse tapir
#

hmmmmmmm same thing, so that means its on the consuming side

fair fossil
#

not sure what "it's on the consuming side" could mean. But you should be able to log everything both server-side and client-side to narrow it down

coarse tapir
#

ignore me momentarily lol

#
cid: undefined

ugh, front end still returns undefined even though the server is serving up the id

fair fossil
#

you're likely reading it wrong client-side.

coarse tapir
#

yeah thats what im guessing, sorry for being a pain....I got to the last step of the testing check and then had to rewrite it all so i'm forgetting simple stuff at this point lmao

let createCustomer = await fetch(`/create-customer?email=${email}&name=${name}`, {method: "POST"}).then(async (customerSentInfo) => {
                        console.log('cid: ' + customerSentInfo);

fair fossil
#

why do you use .then if you use await?

#
let createCustomer = await fetch(`/create-customer?email=${email}&name=${name}`, {method: "POST"});
console.log('cid: ' + createCustomer);```
coarse tapir
#

for some reason the React boilerplate isn't honoring awaits without .thens

#

like that doesn't work either

fair fossil
#

hum

#

Let's take a step back for a sec: do you know how to do a fetch to your server in the first place? Like can you write a complete end-to-end example without anything about Stripe and make that work first?

coarse tapir
#

yeah; it's doing like 5 other fetches before this, it's just this one endpoint thats bugging it up oddly lol

fair fossil
#

My fetch locally looks like this ```
fetch(
"/my_script.php",
{
method: "POST",
body: JSON.stringify(params)
})
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log("Got the response: ", data);
});

coarse tapir
#

yeah the fetch above it works perfectly which is the ocnfusing part lol

  let checkEmail = await fetch(`/search-customers?email=${email}`, {method: 'POST'}).then(async (response) => {
#

knew it was something stupid..... doh forgot to serialize the response from the server as JSON rip

#

thanks all...ill be back again i'm sure of it :v

fair fossil
#

oh damn and you didn't see an error back in the client? I often look at the Network tab in Chrome Developer Tools