removed debug & ensured values exist
This commit is contained in:
parent
c121a91c04
commit
0eb116b96f
1
.gitignore
vendored
1
.gitignore
vendored
@ -116,3 +116,4 @@ dist
|
|||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
test.js
|
12
README.md
12
README.md
@ -1,3 +1,13 @@
|
|||||||
# jotify
|
# jotify
|
||||||
|
|
||||||
It's pronounced "jiff"
|
```
|
||||||
|
gotify = require("jotify")
|
||||||
|
|
||||||
|
gotify.url = "https://gotify.domain.tld"
|
||||||
|
gotify.token = "ABCXYZ"
|
||||||
|
gotify.priority = 7
|
||||||
|
|
||||||
|
gotify.send("Title", "Message")
|
||||||
|
```
|
||||||
|
|
||||||
|
> Pronounced with a hard J
|
25
index.js
25
index.js
@ -10,20 +10,21 @@ gotify = {
|
|||||||
throw "gotify url value empty, please use: gotify.url == 'https://gotify.mydomain.tld'"
|
throw "gotify url value empty, please use: gotify.url == 'https://gotify.mydomain.tld'"
|
||||||
} else if(gotify.token == "") {
|
} else if(gotify.token == "") {
|
||||||
throw "gotify url value empty, please use: gotify.token == 'xyzxyz'"
|
throw "gotify url value empty, please use: gotify.token == 'xyzxyz'"
|
||||||
}
|
} else if(message === undefined) {
|
||||||
if (!priority){
|
throw "gotify message value was undefined"
|
||||||
priority = gotify.priority
|
} else if(title === undefined) {
|
||||||
}
|
throw "gotify title value was undefined"
|
||||||
|
} else {
|
||||||
fetch(gotify.url+'/message?token='+gotify.token, {
|
if (!priority){
|
||||||
method: 'POST',
|
priority = gotify.priority
|
||||||
body: 'title='+title+"&message="+message+"&priority="+priority ,
|
}
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
|
|
||||||
.then(res => res.text())
|
|
||||||
.then(body => console.log(body))
|
|
||||||
|
|
||||||
|
fetch(gotify.url+'/message?token='+gotify.token, {
|
||||||
|
method: 'POST',
|
||||||
|
body: 'title='+title+"&message="+message+"&priority="+priority ,
|
||||||
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = gotify
|
module.exports = gotify
|
Loading…
Reference in New Issue
Block a user