You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a postal mail server working just fine
I can send emails using your node js client with no problem.
now I turned my mail server off,
I wanted to see if my application can candle such a scenario.
but now I am getting an error related to your client.
in my case it says something like :
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at D:\flutterProjects\project_01\node_modules\@atech\postal\Client.js:24:25
in the line 24 to 29 of Client.js
I think instead of:
var json = JSON.parse(content);
if (json.status === 'success') {
resolve(json.data);
} else {
reject(json.data);
}
I think you should do something like this:
try {
var json = JSON.parse(content);
if (json.status === 'success') {
resolve(json.data);
} else {
reject(json.data);
}
} catch (error) {
// reject(error.toString());
var msg = 'cant parse response. please check your connection to the mail server';
reject(msg);
}
I hope this helps,
Thank you
The text was updated successfully, but these errors were encountered:
I'm not using the client library, but use fetch and still get syntax errors while parsing the response (mine seems to have to do with a failed "mysql" connection), found it in caddy logs
ERROR POST /api/v1/send/message (500) event=request transaction=REDACTED controller=LegacyAPI::SendController action=message format=*/* method=POST path=/api/v1/send/message request_id=REDACTED ip_address=REDACTED status=500 db_runtime=4.894985198974609 exception_class=Mysql2::Error::ConnectionError exception_message=Lost connection to MySQL server during query exception_backtrace=/usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `_query'\n/usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `block in query'\n/usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `handle_interrupt'\n/usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `query'
I think the problem is that the postal server has some ambiguous responses under different conditions (maybe sending XML response where JSON is requested by the client?), in which case it shouldn't matter too much where You catch the error.
Responses from the server (2xx-5xx) should result in a valid JSON object, at least if requested with an Accept: application/json header.
Hello developer,
I have a postal mail server working just fine
I can send emails using your node js client with no problem.
now I turned my mail server off,
I wanted to see if my application can candle such a scenario.
but now I am getting an error related to your client.
in my case it says something like :
in the line 24 to 29 of Client.js
I think instead of:
I think you should do something like this:
I hope this helps,
Thank you
The text was updated successfully, but these errors were encountered: