Created with <3 with dartpad.dev.
Created
October 10, 2022 13:34
-
-
Save Jerome-Jumah/00334fd782dd8d9e03e2dc8085a3a347 to your computer and use it in GitHub Desktop.
ubiquitous-durian-3116
This file contains hidden or 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 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
void main() async{ | |
final List<SubSection> subsections = []; | |
final graphQLQuery = { | |
'query': '''query { | |
getSubsections(courseId: 16, sectionId: 16) { | |
id | |
sectionId | |
subtopic | |
orderNum | |
} | |
}''' | |
}; | |
final response = await http | |
.post(Uri.parse('https://7522-197-232-145-163.eu.ngrok.io'), | |
headers: {'Content-Type': 'application/json'}, | |
body: jsonEncode(graphQLQuery) | |
); | |
final result = jsonDecode(response.body); | |
final arr = result['data']['getSubsections']; | |
print(arr); | |
arr.forEach((sub) => subsections | |
.add(SubSection(title: sub['subtopic'], | |
lessons: [], | |
subSectionId: sub['id']) | |
)); | |
print(subsections[0].title); | |
} | |
class SubSection { | |
String title; | |
int subSectionId; | |
List lessons; | |
SubSection( | |
{required this.title, required this.lessons, required this.subSectionId}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment