v0.5.3
This commit is contained in:
parent
30139df2c1
commit
ca4408dd07
2 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tn-api.js",
|
"name": "tn-api.js",
|
||||||
"version": "0.5.2",
|
"version": "0.5.3",
|
||||||
"description": "A Public Template for npm",
|
"description": "A Public Template for npm",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js",
|
"repository": "https://source.thundernetwork.org/ThunderNetworkRaD/tn-api.js",
|
||||||
|
|
|
@ -69,7 +69,9 @@ export default class CreditsManager {
|
||||||
if (amount < 0) throw new Error("Invalid Amount");
|
if (amount < 0) throw new Error("Invalid Amount");
|
||||||
|
|
||||||
let req = await axios.patch(`${this.URL}/credits/${id}`, { amount, to: toPayID }, { headers: { Authorization: `Bearer ${this.token}` } });
|
let req = await axios.patch(`${this.URL}/credits/${id}`, { amount, to: toPayID }, { headers: { Authorization: `Bearer ${this.token}` } });
|
||||||
if (req.status == 403) throw new Error("No Permission");
|
if (req.status == 400 && req.data.error == "TOO_MANY_CREDITS") throw new Error("Not Enought Credits");
|
||||||
|
if (req.status == 403 && req.data.error == "NO_NEGATIVE_AMOUNT") throw new Error("Invalid Amount");
|
||||||
|
else if (req.status == 403) throw new Error("No Permission");
|
||||||
if (req.status == 404) throw new Error("User not Found");
|
if (req.status == 404) throw new Error("User not Found");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue