تقريبا كل مرة لازم ابعت التوكين فعايز اشوف طريقة اسهل من كدا عشان امرر التوكين
انا لما بعمل Sign in بيعملي الـ Token فانا عايز اخد الـ Token دا واخزنه Variable عايز اعمل Variable على مستوى الـ Collection
اكتب فيه الـ Token
ونبعت بيه عادي
بس التوكين بيعمل Expire كل شوية فانا عايز كل مرة اعمل Login ياخد الـ Token يحطه في الـ Variable
فانا هروح على الـ Request بتاع الـ Login واكتب Postman Script ودي هكتبها في الـ Tests
فهو مكتوب JS or TS
وسهل يتفهم بس جايبة من جوجل
لو عايزة على مستوى الـ Collection بغير globals
لـ collectionVariables
واكتب اسم الـ Token
const user = pm.response.json();
pm.test("Has properties", function () {
pm.expect(user).to.have.property('displayName');
pm.expect(user).to.have.property('email');
pm.expect(user).to.have.property('token');
});
if (pm.test("Has properties")) {
pm.collectionVariables.set('Variable_Name', user.token);
}