・dart pub global activate devtools -v 2.8.0を実行したら
"/Users/develien/.pub-cache/hosted/pub.dartlang.org/devtools-2.9.2/build" could not be foundのようなエラーは消えた(参考:https://github.com/flutter/devtools/issues/3549)
・PC本体、エミュレータ、AndroidStudioの再起動
・エミュレータの初期化、変更
・Chromeでの実行
該当箇所のソースコード
client.dart
import 'package:mobile_qiita_app/services/article.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
class Client {
// QiitaAPIで記事を取得
static Future<List<Article>> fetchArticle() async {
var url = 'https://qiita.com/api/v2/items';
var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
final List<dynamic> jsonResponse = json.decode(response.body);
return jsonResponse.map((json) => Article.fromJson(json)).toList();
}
else {
throw Exception('Request failed with status: ${response.statusCode}');
}
}
}
概要
Flutterの最終課題でFeedPageを作成していたところ、昨日まで可能だった記事の取得ができなくなってしまいました。 解決方法を教えていただければ幸いです。 よろしくお願いします。
実装したい内容
QiitaAPIを利用して記事一覧を表示する
現状
・QiitaAPIで記事を取得しようとするとresponse.statusCode = 403が返されて記事の取得ができない ・昨日までは記事もタグも問題なく取得できていた ・取得に成功することもある ・エミュレータはインターネットに接続されていて機内モードにもなっていない ・エミュレータのブラウザの使用やWebViewでQiitaのログインページを表示することは可能
試したこと
・
dart pub global activate devtools -v 2.8.0
を実行したら"/Users/develien/.pub-cache/hosted/pub.dartlang.org/devtools-2.9.2/build" could not be found
のようなエラーは消えた(参考:https://github.com/flutter/devtools/issues/3549) ・PC本体、エミュレータ、AndroidStudioの再起動 ・エミュレータの初期化、変更 ・Chromeでの実行該当箇所のソースコード
client.dart
feed_page.dart