Skip to content

Instantly share code, notes, and snippets.

@mikejholly
Created January 17, 2014 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikejholly/8474441 to your computer and use it in GitHub Desktop.
Save mikejholly/8474441 to your computer and use it in GitHub Desktop.
# Get API token for authorization header
token = session.get "apiToken"
id = record.get "_id"
###
xhr = new XMLHttpRequest()
xhr.onreadystatechange = ->
console.log arguments
xhr.open "DELETE", "http://#{ENV.domains.crud}/api/v1/pathways/#{id}"
xhr.setRequestHeader "Authorization", "Token token=#{token}"
xhr.setRequestHeader "Content-Type", "application/json"
xhr.send JSON.stringify record.toJSON()
console.log record.toJSON()
###
# Send pathway to server
$.ajax
url: "http://#{ENV.domains.crud}/api/v1/pathways/#{id}"
method: "DELETE"
dataType: "json"
contentType: "application/json"
data:
pathway: record.toJSON()
headers:
Authorization: "Token token=#{token}"
.then (json) ->
record.didDeleteRecord record, json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment