#Empress Brosephine-create-customer
1 messages · Page 1 of 1 (latest)
Hey Hanzo!
cid: [object Response] RegistrationForm.js:74
are you correctly parsing the response coming from your server?
It doesn't look like a plain old javascript object
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
email: req.query.email,
name: req.query.name
});
const customerId = customer.id;```
hmmmmmmm same thing, so that means its on the consuming side
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
ignore me momentarily lol
cid: undefined
ugh, front end still returns undefined even though the server is serving up the id
you're likely reading it wrong client-side.
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);
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);```
for some reason the React boilerplate isn't honoring awaits without .thens
like that doesn't work either
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?
yeah; it's doing like 5 other fetches before this, it's just this one endpoint thats bugging it up oddly lol
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);
});
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
oh damn and you didn't see an error back in the client? I often look at the Network tab in Chrome Developer Tools