       issue
     .then (issue) ->
       fetch "#{jiraUrl}/rest/api/2/issue",
-        headers: headers
         method: "POST"
         body: JSON.stringify issue
-    .then (res) ->
-      checkStatus res
-    .then (res) ->
-      parseJSON res
     .then (json) ->
       issue = json.key
       msg.send "<@#{msg.message.user.id}> Ticket created: #{jiraUrl}/browse/#{issue}"


  priorities = JSON.parse process.env.HUBOT_JIRA_PRIORITIES_MAP if process.env.HUBOT_JIRA_PRIORITIES_MAP

  parseJSON = (response) ->
    return response.json()

  checkStatus = (response) ->
    if response.status >= 200 and response.status < 300
      return response
    else
      error = new Error(response.statusText)
      error.response = response
      throw error

  lookupSlackUser = (username) ->
    users = robot.brain.users()

      message = ""
      id = ""
      ticket = issue.trim().toUpperCase()
      fetch "#{jiraUrl}/rest/api/2/issue/#{ticket}"
      .then (json) ->
        id = json.id
        message = """
