Created
January 10, 2022 15:09
-
-
Save TheCompez/1f94455136a38ea622ec493760d5bba1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick | |
Window { | |
width: 640 | |
height: 480 | |
visible: true | |
title: qsTr("Hello World") | |
function jsonApiRequest() { | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) { | |
print('HEADERS_RECEIVED') | |
} else if(xhr.readyState === XMLHttpRequest.DONE) { | |
var json = JSON.parse(xhr.responseText.toString()) | |
console.log("UserId: " + json.userId) | |
} | |
} | |
xhr.open("GET", "https://jsonplaceholder.typicode.com/todos/1"); | |
xhr.send(); | |
} | |
Component.onCompleted: { | |
jsonApiRequest(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment