Skip to content

Commit 678f072

Browse files
authored
Merge pull request #370 from ricardo-a-alves-alb/fix/fetchjson-local
fix: fetchJson fails on file protocol
2 parents f81f94c + 517afe2 commit 678f072

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/helpers/fetchJson.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export default (file) => {
2222
var xhr = new XMLHttpRequest()
2323
xhr.onreadystatechange = function() {
2424
if (xhr.readyState == XMLHttpRequest.DONE) {
25-
if (xhr.status === 200) resolve(JSON.parse(xhr.responseText))
25+
// file protocol returns 0
26+
// http(s) protocol returns 200
27+
if (xhr.status === 0 || xhr.status === 200) resolve(JSON.parse(xhr.responseText))
2628
else reject(xhr.statusText)
2729
}
2830
}

0 commit comments

Comments
 (0)