Skip to content

Commit 0bb3f10

Browse files
committed
Adjust for api changes in the response.
1 parent 361faf3 commit 0bb3f10

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,20 @@ async function sendRequest(namespace, text, level = 'INFO', options = {}) {
8080
try {
8181
const response = await fetch(options.url, request)
8282
const body = await response.json()
83-
if (!body.ok && body.name !== 'notificationQueued') {
84-
return { error: { title: 'ApiRequestFailed', message: 'Error sending Notification to PushNotice API' } }
83+
if (body.status !== 'ok') {
84+
return {
85+
error: {
86+
title: 'ApiRequestFailed',
87+
message: 'Error sending Notification to PushNotice API',
88+
body,
89+
},
90+
}
8591
}
92+
93+
return body
8694
} catch {
8795
return { error: { title: 'ApiRequestFailed', message: 'Error sending Notification to PushNotice API' } }
8896
}
89-
90-
return { success: true }
9197
}
9298

9399
function pnotice(namespace, options = {}) {

0 commit comments

Comments
 (0)