|
|
@ -1,7 +1,9 @@ |
|
|
|
<h1>Javascript</h1> |
|
|
|
<p>Below is an example of making a HTTP request to SITE_NAME from Node.js.</p> |
|
|
|
<div class="js highlight"><pre><span></span><code><span class="kd">var</span> <span class="nx">https</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'https'</span><span class="p">);</span> |
|
|
|
<span class="nx">https</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"PING_URL"</span><span class="p">);</span> |
|
|
|
<span class="nx">https</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">'PING_URL'</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">'error'</span><span class="p">,</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span> |
|
|
|
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'Ping failed: '</span> <span class="o">+</span> <span class="nx">err</span><span class="p">)</span> |
|
|
|
<span class="p">});</span> |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
|
|
|
|