feat: add postrequest script to save access_token in active environment
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
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:
@@ -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": {
|
"request": {
|
||||||
|
|||||||
Reference in New Issue
Block a user