Hi!
I’m trying to return an HTML response from a get_httpFunction:
import { fetch } from ‘wix-fetch’
import { response } from ‘wix-http-functions’
export async function get_verifyPayment(request) {
let { transaction_id } = request.query
let transactionResponse = await fetch(https://api.qvo.cl/transations/${transaction_id}
, {
method: ‘GET’,
headers: {
‘Authorization’: ‘Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb21tZXJjZV9pZCI6ImNvbV8yeGtscmR5WmdSMkc4QTVBZVlDd2lnIiwiYXBpX3Rva2VuIjp0cnVlfQ.5_JozwPGWzyyi9wC1lQq8VDZasxAYgj2gK9fghVqMPY’,
‘Content-Type’: ‘application/json’
}
})
console.log(‘transactionResponse:’, transactionResponse)
let wixResponse = {
headers: {
“content-type”: “text/html”,
“charset”: “utf-8”
}
}
if (transactionResponse.status === ‘successfull’) {
console.log(‘payment completed’)
// Redirect to voucher page
wixResponse.body = <html> <head> <title>Pago Exitoso</title> </head> <body> <h1>Pago realizado exitosamente!</h1> <p>Para volver a revive haz <a href="https://revivehogar.cl" target="_self">aquí</a></p> </body> </html>
return response(wixResponse)
} else {
console.log(‘payment rejected’)
wixResponse.body = ‘Pago Fallido
Ups!
Algo salió mal con el pago.
Reitenta el pago aquí
’return response(wixResponse)
}
}
The thing is that the browser gets a json response “content-type”, even after I’ve changed the header.
Any tips to return something different than json?
I tried to redirect from the backend but haven’t been successful either.
Thanks in advance