所以我知道我可以对此投票,因为我已经在寻找如何解决这个问题,并且发现它之前已被问过,似乎很多人都遇到了问题,但我没有发现帮助我解决了自己的问题。
我正在使用fetch()
这样的Request()
对象尝试var request = new Request('https://secure.realcove.com/api.php');
fetch(request).then(function (response) {
return response.json().then(function (json) {
console.log(json.name);
});
});
内容(这只是一个示例,可能无法运行,因此无需尝试运行它):
Request
所以我不知道该怎么办,因为我甚至不能按照我想要的方式使用WebStorm 2017.1
Build #WS-171.3780.79
JRE: 1.8.0_112-release-736-b13 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.5
,因为看起来WebStorm有冲突并认为它不是我的意思需要它。
如何解决这个问题的任何建议或想法将不胜感激。到目前为止我所尝试的一切都没有奏效。
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
//Google Analytics
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "xxxxxxxxxxx")
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true
// Optional: set Logger to VERBOSE for debug information.
// Remove before app release.
gai.logger.logLevel = .verbose;
return true
}
我知道我的JS正在运行ECMAScript 5.1,如果这很重要的话。如果需要,请参阅“文档”链接:Request - Web APIs| MDN
答案 0 :(得分:2)
据我所知,fetch API没有可用的TypeScript存根。
我可以建议以下内容:使用MenuItem
或npm install whatwg-fetch
在某处(在您的项目中或某个不同的位置)安装fetch polyfill,然后将下载的bower install fetch
包含为库在你的项目中:
这对我来说很好