안녕하세요! 강의 Chat App - Part 1 회원가입 부분에서 firebase 관련 에러가 납니다.

app.storage가 정의되어있지 않다고 뜨면서 Sign up이 되지 않습니다.
처음에 Firebase 버전이 안맞아서 계속 에러가 떠서 게시판에 검색 한 후에 강사님이 올려주신 코드를 참고하여 강의 코드와는 약간 다르게 수정하였는데, 그것때문인지는 몰라도 계속 같은 에러가 발생합니다.
<2023.02.07 22:05 수정>
const ref = app.storage().ref(`/profile/${user.uid}/photo/png`);위 부분에 오타가 있어서
const ref = app.storage().ref(`/profile/${user.uid}/photo.png`);이렇게 수정하였는데도 똑같이 오류가 납니다.
아래는 깃헙 주소입니다.
https://github.com/frica12/React-native/tree/main/rn-chat
아래는 firebase.js 코드입니다.
import { initializeApp } from "firebase/app";
import {
getAuth,
signInWithEmailAndPassword,
createUserWithEmailAndPassword,
} from "firebase/auth";
import config from "../firebase.json";
const app = initializeApp(config);
const auth = getAuth(app);
export const signin = async ({ email, password }) => {
const { user } = await signInWithEmailAndPassword(auth, email, password);
return user;
};
const uploadImage = async (uri) => {
if (uri.startsWith("https")) {
return uri;
}
const blob = await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
resolve(xhr.response);
};
xhr.onerror = function () {
reject(new TypeError("Network request failed"));
};
xhr.responseType = "blob";
xhr.open("GET", uri, true);
xhr.send(null);
});
const user = auth.currentUser;
const ref = app.storage().ref(`/profile/${user.uid}/photo/png`);
const snapshot = await ref.put(blob, { contentType: "image/png" });
blob.close();
return await snapshot.ref.getDownloadURL();
};
export const signup = async ({ name, email, password, photo }) => {
const { user } = await createUserWithEmailAndPassword(auth, email, password);
const photoURL = await uploadImage(photo);
await user.updateProfile({ displayName: name, photoURL });
};
回答 1
1
안녕하세요,
firebase 9 버전을 사용중이시네요.
강의는 firebase 8 버전으로 촬영되어 9버전과 사용방법에 차이가 있습니다.
9버전으로 진행하신다면, 아래 링크에서 코드를 확인하시기 바랍니다.
https://github.com/Alchemist85K/inflearn-react-native
현재 발생한 에러는 uploadImage 함수 안에 있는 storage 관련 코드에 문제가 있습니다.
(코드 기준 37 line)
아래 링크를 참고해서 uploadImage 함수를 수정하시기 바랍니다.
https://github.com/Alchemist85K/inflearn-react-native/blob/main/rn-chat/src/firebase.js
주의할 점은 app.storage가 아니라 storage관련된 함수를 따로 import 해줘야 합니다.
조금 더 자세한 내용은 firebase 공식 문서를 확인하시기 바랍니다.
https://firebase.google.com/docs/reference/js/storage
감사합니다.
맥북 m4에서 nvm으로 설치불가
0
103
2
expo 사용하지 않고 앱 실행 시, 데이터 불러오기
0
334
1
리덕스강의는 없나요?
0
264
1
선생님 도와주세요 ㅠㅠ (로그인, 회원가입, 콘솔 에러)
0
497
1
버젼 업데이트
0
411
1
expo start중 metro bundler가 같이 실행되지 않아요
0
497
1
모바일 expo 실행오류
0
847
1
안드로이드에서 expo실행이 안되요
0
834
2
터미널 다운 및 사용방법
0
291
1
expo init 에러
0
730
2
안녕하세요. 스택네비게이션 문제 질문드립니다 ㅜ
0
318
1
배포중 에러 해결이 안되네요.. ㅜㅜ
1
3215
1
styled-components 에러
0
396
1
OS 네이트브 코드를 개발하면서 UI 를 리액트 네이티브로
0
481
1
저장하면 바뀐값들 보여야하는데 재렌더링이 안일어납니다..
0
494
1
안드로이드스튜디오 EXPO 어플 튕깁니다 ㅠㅠ
0
276
1
styled component를 사용하면 터집니다 ㅠㅠ
0
409
1
attrs, 속성, props 가 혼란스럽습니다.
0
347
1
안녕하세요, 강의 잘 들었습니다 :) RN과 파이어베이스 관련해서 질문드릴게 있습니다!
0
576
1
자꾸 The request timed out 에러가 뜹니다 .
0
1905
1
코드 좀 봐주세요 버튼 두개가 생성이 안되요
0
278
1
expo 실행시 스타일 속성 바로 보려면 어디서 보나요?
0
425
1
자바스크립트 () => 의미는요???
0
440
2
어플 프로젝트 이름을 만든후 윈도우 탐색기에서 이름을 수정해도 되나요?
0
678
2

