Skip to content

Commit 58ac488

Browse files
committed
hide api key
1 parent 62f426b commit 58ac488

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Random-Generator/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ yarn-error.*
4040
expo-env.d.ts
4141
# @end expo-cli
4242

43-
.env
43+
.env
44+
env.tsx

Random-Generator/app/(tabs)/unsplash.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import { StyleSheet, Text, View, TouchableOpacity, Image, Linking } from 'react-native';
3+
// create env.tsx instead
4+
import { UNSPLASH_API } from '../../env';
35

46
export default function TabOneScreen() {
57
const [imageData, setImageData] = useState<any>(null); // Specify type as 'any'
@@ -10,7 +12,7 @@ export default function TabOneScreen() {
1012

1113
// Function to fetch a new random image
1214
const fetchNewImage = () => {
13-
const clientID = process.env.UNSPLASH_API;
15+
const clientID = UNSPLASH_API;
1416
const endpoint = `https://api.unsplash.com/photos/random/?client_id=${clientID}`;
1517

1618
fetch(endpoint)

0 commit comments

Comments
 (0)