最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cannot read properties of undefined (reading 'path') Firebase ref function conflict - Stack Overflo

programmeradmin5浏览0评论

Error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'path')

according to my testing,

   import { getStorage, ref, uploadBytesResumable, getDownloadURL } 
    from ".1.1/firebase-storage.js";
    
    import { getDatabase, set, child, get, update, remove } 
    from ".1.1/firebase-database.js";
    
    const realdb = getDatabase();

the error is becuase ref( ) function from firebase-storage is different from ref( ) from firebase-database

but i can import only one of the function, so what to do? to save the downloadURL i need both (firebase-storage) and (firebase-database).

Error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'path')

according to my testing,

   import { getStorage, ref, uploadBytesResumable, getDownloadURL } 
    from "https://www.gstatic./firebasejs/9.1.1/firebase-storage.js";
    
    import { getDatabase, set, child, get, update, remove } 
    from "https://www.gstatic./firebasejs/9.1.1/firebase-database.js";
    
    const realdb = getDatabase();

the error is becuase ref( ) function from firebase-storage is different from ref( ) from firebase-database

but i can import only one of the function, so what to do? to save the downloadURL i need both (firebase-storage) and (firebase-database).

Share Improve this question edited Oct 11, 2021 at 18:04 Dharmaraj 51k8 gold badges67 silver badges98 bronze badges asked Oct 11, 2021 at 17:59 Hassaan RazaHassaan Raza 1974 silver badges14 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You can just rename one of the imports like this:

import { getStorage, ref as storageRef } from "https://www.gstatic./firebasejs/9.1.1/firebase-storage.js";

Then make sure you used storageRef() instead of ref() for storage in your code.

Make sure you are imported and initialized the app before use some storage functions.

import { initializeApp } from "firebase/app";


initializeApp(firebaseConfig);

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论