Skip to content

Instantly share code, notes, and snippets.

@jsdf
jsdf / Fetch-API-cheat-sheet.md
Last active August 18, 2022 20:23
Fetch API cheat sheet

fetch api cheat sheet

get JSON

fetch('/things/10', {
  credentials: 'same-origin',
  headers: {
    'accept': 'application/json'
  }
words = Hash.new 0
Dir.glob("#{ARGV.first}/**/*").reject { |file| File.directory? file }.each do |file|
File.read(file).scan(/\w+/).each { |word| words[word] += 1 }
end
File.open('counts-descreasing-ruby', 'w') do |file|
file << words.sort_by { |word, count| count }.reverse.map { |word, count| "#{word}\t#{count}" }.join("\n")
end