Reputation: 1
I have created a .env file and installed the "react-native-config " package, but the variable values are not displayed (on ios).
Could you help me with this?
Thanks
terminal :
LOG Running "myRecipes" with {"rootTag":51,"initialProps":{}}
LOG ALL RECIPES ===> []
LOG -------------> undefined
LOG Error in getAllRecipes: [Error: Cannot load an empty url]
.env
ENV=dev
const URL_API=https://api.spoonacular.com/recipes/complexSearch
const API_KEY=2asjioezarnfzeopa
const MAX_PER_PAGE=30
App.js
import { useDispatch } from "react-redux"
import axios from "axios"
import Config from "react-native-config"
import { addRecipes } from "../../redux/actions"
export const useFetchRecipes = () => {
const dispatch = useDispatch()
const getAllRecipes = async () => {
console.log('------------->',Config.API_KEY);
...
}
return {
getAllRecipes
}
}
Upvotes: 0
Views: 2156
Reputation: 11
The issue is in your .env file, remove the constant declaration as shown following:
ENV=dev
URL_API=https://api.spoonacular.com/recipes/complexSearch
API_KEY=2asjioezarnfzeopa
MAX_PER_PAGE=30
Upvotes: 1