You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
343 B

3 years ago
export default def upload_json_file e
return new Promise! do |resolve|
let files = e.target.files
resolve no if files.length < 1
let file = files[0]
let reader = new FileReader()
reader.onloadend = do
try
resolve JSON.parse(reader.result)
catch
resolve no
reader.onerror = do
resolve no
reader.readAsText(file)