Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Fetch:类型为';字符串|未定义';不可分配给类型为';请求信息';_Javascript_Typescript_Fetch - Fatal编程技术网

Javascript Fetch:类型为';字符串|未定义';不可分配给类型为';请求信息';

Javascript Fetch:类型为';字符串|未定义';不可分配给类型为';请求信息';,javascript,typescript,fetch,Javascript,Typescript,Fetch,我在fetch函数的“fetchUrl”参数中收到以下错误 “string | undefined”类型的参数不可分配给参数 类型为“RequestInfo” 在这个函数中 let fetchUrl = getBaseUrlNative( process.env.APP_DATA, `/v2/marketing/app/file/${file}?cookies=${cookieSess}&expires=${Date.now()}`) await fetch(fetchUrl,

我在fetch函数的“fetchUrl”参数中收到以下错误

“string | undefined”类型的参数不可分配给参数 类型为“RequestInfo”

在这个函数中

let fetchUrl = getBaseUrlNative( process.env.APP_DATA, `/v2/marketing/app/file/${file}?cookies=${cookieSess}&expires=${Date.now()}`)

    await fetch(fetchUrl, { method: 'get' , cache:"no-store" , headers: {
        'Cache-Control': 'no-cache'
      }})
         .then(res => res.blob())
         .then(res => {  .......
getBaseUrlNative是

export const getBaseUrlNative = (eUrl : string | undefined, ext : string | undefined) => {
    try {
        if (!eUrl) throw new Error("Error .")
        return ext ? eUrl+ext : eUrl;
    } catch (err) {
        console.log(err)
    }
}
在fetch函数中使用任何数据类型来禁止类型检查

let fetchUrl=getBaseUrlNative(process.env.APP_DATA,`/v2/marketing/APP/file/${file}?cookies=${cookiesses}&expires=${Date.now()}`)
等待获取(fetchUrl,{method:'get',缓存:“no store”,标题:{
“缓存控制”:“无缓存”
}})
.then(res=>res.blob())
.然后(res=>{……