NEO-48: fix Bruno pre-request baseUrl for branch_already_chosen
Use getEnvVar fallback and axios like other collection scripts; Invalid URL when baseUrl was undefined in pre-request.pull/83/head
parent
3ba8300652
commit
d5b65c94f6
|
|
@ -10,39 +10,40 @@ docs {
|
||||||
}
|
}
|
||||||
|
|
||||||
script:pre-request {
|
script:pre-request {
|
||||||
const baseUrl = bru.getVar("baseUrl");
|
const axios = require("axios");
|
||||||
const grant = await bru.sendRequest({
|
const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
|
||||||
method: "POST",
|
const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
|
||||||
url: `${baseUrl}/game/players/dev-local-1/skill-progression`,
|
const jsonHeaders = { headers: { "Content-Type": "application/json" } };
|
||||||
headers: { "Content-Type": "application/json" },
|
const grant = await axios.post(
|
||||||
data: {
|
`${baseUrl}/game/players/${playerId}/skill-progression`,
|
||||||
|
{
|
||||||
schemaVersion: 1,
|
schemaVersion: 1,
|
||||||
skillId: "salvage",
|
skillId: "salvage",
|
||||||
amount: 100,
|
amount: 100,
|
||||||
sourceKind: "activity",
|
sourceKind: "activity",
|
||||||
},
|
},
|
||||||
});
|
jsonHeaders,
|
||||||
|
);
|
||||||
if (grant.status !== 200) {
|
if (grant.status !== 200) {
|
||||||
throw new Error(`salvage grant failed: ${grant.status}`);
|
throw new Error(`salvage grant failed: ${grant.status}`);
|
||||||
}
|
}
|
||||||
const firstPick = await bru.sendRequest({
|
const firstPick = await axios.post(
|
||||||
method: "POST",
|
`${baseUrl}/game/players/${playerId}/perk-state`,
|
||||||
url: `${baseUrl}/game/players/dev-local-1/perk-state`,
|
{
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
data: {
|
|
||||||
schemaVersion: 1,
|
schemaVersion: 1,
|
||||||
skillId: "salvage",
|
skillId: "salvage",
|
||||||
tierIndex: 1,
|
tierIndex: 1,
|
||||||
branchId: "scrap_efficiency",
|
branchId: "scrap_efficiency",
|
||||||
},
|
},
|
||||||
});
|
jsonHeaders,
|
||||||
|
);
|
||||||
if (firstPick.status !== 200 || firstPick.data?.selected !== true) {
|
if (firstPick.status !== 200 || firstPick.data?.selected !== true) {
|
||||||
throw new Error(`tier-1 pick failed: ${firstPick.status} ${JSON.stringify(firstPick.data)}`);
|
throw new Error(`tier-1 pick failed: ${firstPick.status} ${JSON.stringify(firstPick.data)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
url: {{baseUrl}}/game/players/dev-local-1/perk-state
|
url: {{baseUrl}}/game/players/{{playerId}}/perk-state
|
||||||
body: json
|
body: json
|
||||||
auth: none
|
auth: none
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue