[英]Unsafe assignment/member access of an `any` value with fetch api
I don't know how to correct the linting error.我不知道如何纠正掉毛错误。 Perhaps I just don't fully understand the issue, but it doesn't seem to matter what I do.
也许我只是不完全理解这个问题,但我做什么似乎并不重要。 I just can't seem to get rid of the error.
我似乎无法摆脱错误。 I'd rather not disable the rule unless the issue is that my linting rules are just too strict.
我宁愿不禁用该规则,除非问题是我的 linting 规则太严格了。
I'm using this in a fetch
with google geocode api.我正在使用 google geocode api
fetch
它。
fetch(uri)
.then(res => (res.json() as Promise<google.maps.GeocoderResponse>))
.then(data => {
const result = data.results[0].geometry;
// Unsafe assignment of an `any` value.
// Unsafe member access .results on an `any` value.
})
Any help would be appreciated.任何帮助,将不胜感激。
Have you tried specifying the type of data
?您是否尝试过指定
data
类型?
.then((data: <DEFINE TYPE HERE>) => {
const result = data.results[0].geometry;
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.