ghardin137
ghardin1373y ago

Getting HTML 200 from fetch instead of JSON

did you request json from the backend? not sure if it expects to be told what to return
37 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin1373y ago
oh yeah response.json is going to be a function ok so the backend should never return anything BUT json
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin1373y ago
these are on different ports yeah?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin1373y ago
i mean http://localhost:8080 vs http://localhost:8081
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin1373y ago
ah so that's one problem
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin1373y ago
you're making the request in your frontend, to your front end server
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin1373y ago
fetch(`/payment_intents/${paymentIntent.id}/capture`, {
fetch(`/payment_intents/${paymentIntent.id}/capture`, {
says fetch from the same origin i'm on /payment_intents/${paymentIntent.id}/capture
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin1373y ago
it doesn't know that your backend is on a different server it only knows what you told it so you'd either want to tell it that and deal with CORS or you'd set up proxying
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View