feat: add postrequest script to save access_token in active environment
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
minguezsanzjuanjose
2026-04-18 14:25:24 +02:00
parent 35e1d38859
commit 1a53cd3918

View File

@@ -28,6 +28,29 @@
"}"
]
}
},
{
"listen": "postrequest",
"script": {
"type": "text/javascript",
"exec": [
"// Comprobamos si la respuesta es exitosa",
"if (pw.response.status === 200) {",
" // Si el body ya es un objeto no hace falta JSON.parse",
" const body = typeof pw.response.body === 'string'",
" ? JSON.parse(pw.response.body)",
" : pw.response.body;",
"",
" if (body.access) {",
" // Guardamos el token en el entorno actual",
" pw.env.set(\"access_token\", body.access);",
" console.log(\"✅ Token guardado correctamente\");",
" } else {",
" console.log(\"❌ No se encontró el campo 'access' en la respuesta\");",
" }",
"}"
]
}
}
],
"request": {