我有env var SERVER_URL=localhost:8000
config.js
export const SERVER_URL = process.env.SERVER_URL;
export { SERVER_URL as default };
Run Code Online (Sandbox Code Playgroud)
和行动:
function fetchData(apiUrl, timeout) {
return timeoutPromise(timeout || 15000, fetch(`${SERVER_URL}${apiUrl}`))
.then(checkHttpStatus)
.then(parseJSON);
}
Run Code Online (Sandbox Code Playgroud)
但是在使用之后fetchData
我得到了http://localhost:8000/undefined/some_api
来自这里的idk undefined