Log in New API Help About

Using the dpaste.com API with Javascript

379 bytes of JavaScript
Created 5 months, 3 weeks ago by dpaste.com
https://dpaste.com/898G5RRP7
SOFT WRAP RAW TEXT DUPLICATE DIFF
async function dpaste(content) {
  var response = await fetch("https://dpaste.com/api/", {
    method: "POST",
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    body: "content=" + encodeURIComponent(content) + "&syntax=js",
  });
  return response.text();
}

// Usage:
dpaste("alert('JS content')").then(paste_url => { console.log(paste_url) });