<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Sending html mail from API]]></title><description><![CDATA[<p dir="auto">I've tried reproducing code that works fine in one api to another(/new) api. I've checked and double checked, but I'm most likely overlooking something. From what I've concluded from my limited knowledge on debugging, is that request(urlTemplate) does nothing. And yes, the package 'request' is selected.</p>
<pre><code>            var urlTemplate = "https://api.appdrag.com/NewsletterViewer.aspx?newsletterID=2943&amp;appID=webconnect-374b23"; // Replace with your own HTML template
            //console.log(urlTemplate);
            request(urlTemplate, {
                encoding: null
            }, function(error, response, body) {
                console.log(response);
                if (!error &amp;&amp; response.statusCode == 200) {
                    if (response.headers['content-encoding'] == 'gzip') { // If template is located on AppDrag, file is GZIP by default
                        zlib.gunzip(body, function(err, dezipped) {
                            emailContent = dezipped.toString();
                            processTemplate();
                        });
                    } else {
                        emailContent = body.toString();
                        processTemplate();
                    }
                } else {
                    callback(null, "File not found");
                }
            });
</code></pre>
<p dir="auto">Also, I noticed that the package 'request' is deprecated. Is this something I should worry about right now?</p>
<p dir="auto"><img src="/assets/uploads/files/1608567019396-screenshot-2020-12-21-at-17.10.02.png" alt="Screenshot 2020-12-21 at 17.10.02.png" class="img-responsive img-markdown" /><br />
<a href="https://www.npmjs.com/package/request" rel="nofollow ugc">https://www.npmjs.com/package/request</a></p>
]]></description><link>https://community.appdrag.com/topic/601/sending-html-mail-from-api</link><generator>RSS for Node</generator><lastBuildDate>Fri, 12 Jun 2026 05:41:47 GMT</lastBuildDate><atom:link href="https://community.appdrag.com/topic/601.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Dec 2020 16:10:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sending html mail from API on Tue, 22 Dec 2020 13:40:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/9">@Daniel-Mulroy</a> thanks for the tip!</p>
]]></description><link>https://community.appdrag.com/post/2349</link><guid isPermaLink="true">https://community.appdrag.com/post/2349</guid><dc:creator><![CDATA[Dick Honing]]></dc:creator><pubDate>Tue, 22 Dec 2020 13:40:34 GMT</pubDate></item><item><title><![CDATA[Reply to Sending html mail from API on Tue, 22 Dec 2020 13:25:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/2">@Wassim</a> said in <a href="/post/2344">Sending html mail from API</a>:</p>
<blockquote>
<p dir="auto"><a href="https://stackoverflow.com/questions/41412512/node-js-promise-request-return" rel="nofollow ugc">https://stackoverflow.com/questions/41412512/node-js-promise-request-return</a></p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/190">@Dick-Honing</a> I've used the package 'request-promise-native' which allows you to await a request.</p>
<p dir="auto">I recommend checking it out, it's been working great for me:<br />
<a href="https://www.npmjs.com/package/request-promise-native" rel="nofollow ugc">https://www.npmjs.com/package/request-promise-native</a></p>
]]></description><link>https://community.appdrag.com/post/2348</link><guid isPermaLink="true">https://community.appdrag.com/post/2348</guid><dc:creator><![CDATA[Daniel Mulroy]]></dc:creator><pubDate>Tue, 22 Dec 2020 13:25:30 GMT</pubDate></item><item><title><![CDATA[Reply to Sending html mail from API on Tue, 22 Dec 2020 09:53:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/2">@Wassim</a> thanks for taking your time to help met out! I'm still learning JavaScript and the promise/async was still om my todo list. Now I think it's time to dive into this. I already collected some reading material, which might be interesting to others as well ...</p>
<p dir="auto"><a href="https://www.w3schools.com/js/js_promise.asp" rel="nofollow ugc">https://www.w3schools.com/js/js_promise.asp</a></p>
<p dir="auto"><a href="https://www.freecodecamp.org/news/javascript-from-callbacks-to-async-await-1cc090ddad99/" rel="nofollow ugc">https://www.freecodecamp.org/news/javascript-from-callbacks-to-async-await-1cc090ddad99/</a></p>
<p dir="auto"><a href="https://medium.com/better-programming/callbacks-vs-promises-in-javascript-1f074e93a3b5" rel="nofollow ugc">https://medium.com/better-programming/callbacks-vs-promises-in-javascript-1f074e93a3b5</a></p>
<p dir="auto"><a href="https://medium.com/better-programming/should-i-use-promises-or-async-await-126ab5c98789" rel="nofollow ugc">https://medium.com/better-programming/should-i-use-promises-or-async-await-126ab5c98789</a></p>
]]></description><link>https://community.appdrag.com/post/2345</link><guid isPermaLink="true">https://community.appdrag.com/post/2345</guid><dc:creator><![CDATA[Dick Honing]]></dc:creator><pubDate>Tue, 22 Dec 2020 09:53:54 GMT</pubDate></item><item><title><![CDATA[Reply to Sending html mail from API on Tue, 22 Dec 2020 09:36:29 GMT]]></title><description><![CDATA[<p dir="auto">Ok,<br />
Your issue is due to the use of ASYNC / AWAIT.</p>
<p dir="auto">Request is not promise based so you can't await it (and you don't do it at the moment, but your function is killed before it's called as it is async).</p>
<p dir="auto">You can either<br />
switch to a non async function globally and switch the rest of your code<br />
or<br />
follow this solution : <a href="https://stackoverflow.com/questions/41412512/node-js-promise-request-return" rel="nofollow ugc">https://stackoverflow.com/questions/41412512/node-js-promise-request-return</a></p>
]]></description><link>https://community.appdrag.com/post/2344</link><guid isPermaLink="true">https://community.appdrag.com/post/2344</guid><dc:creator><![CDATA[Wassim]]></dc:creator><pubDate>Tue, 22 Dec 2020 09:36:29 GMT</pubDate></item><item><title><![CDATA[Reply to Sending html mail from API on Tue, 22 Dec 2020 09:03:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/2">@Wassim</a> I sent you the code by mail ...</p>
]]></description><link>https://community.appdrag.com/post/2343</link><guid isPermaLink="true">https://community.appdrag.com/post/2343</guid><dc:creator><![CDATA[Dick Honing]]></dc:creator><pubDate>Tue, 22 Dec 2020 09:03:22 GMT</pubDate></item><item><title><![CDATA[Reply to Sending html mail from API on Tue, 22 Dec 2020 07:22:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">We would need the whole code to help you debug it. Is process template in your function?</p>
<p dir="auto">Request is deprecated yes but for the use you have of it in this case (loading a remote url) you don't have to worry at all.</p>
]]></description><link>https://community.appdrag.com/post/2341</link><guid isPermaLink="true">https://community.appdrag.com/post/2341</guid><dc:creator><![CDATA[Wassim]]></dc:creator><pubDate>Tue, 22 Dec 2020 07:22:57 GMT</pubDate></item></channel></rss>