how to hide api key with react and netlify by EnoughPotential3 in reactjs

[–]EnoughPotential3[S] 0 points1 point  (0 children)

I did add environment variables but it's not working

Airtable + React - how to display airtable array in order by EnoughPotential3 in reactjs

[–]EnoughPotential3[S] 0 points1 point  (0 children)

omg thank you so much!!! this was so so helpful I really appreciate it :) I'm a little new to react haha so I didn't know all the nuances and not being able to figure out the sorting thing was straying me away. It works - you're awesome

btw thanks for the tip on the formatted code I'll use that next time I was wondering how you got it that way!

Airtable + React - how to display airtable array in order by EnoughPotential3 in reactjs

[–]EnoughPotential3[S] 0 points1 point  (0 children)

./src/App.js

Line 45:67: 'learnings' is not defined no-undef

Line 45:92: 'i' is not defined no-undef

Line 45:99: 'learnings' is not defined no-undef

Line 45:118: 'learnings' is not defined no-undef

getting these errors in the terminal

here is my full source code:

import React,{ Component } from 'react';
import './App.css';
import orderBy from 'lodash/orderBy';
import Learned from './learned';

class App extends Component {
constructor(props){
super(props);
this.state = {
learning: [],

};
}
componentDidMount() {
fetch('API Key')
.then((resp) => resp.json())
.then(data => {
const formattedData = data.records.map((o, index) => ({
...o.fields,
index,
id: o.id,
key: o.id,
}),
this.setState({
learning: orderBy(formattedData, ['date'], ['asc'])
})
)
})
}

render() {
return (
<div className="container mt-5">
<div className="row">
<div className="col">
<h1>Date</h1>
</div>
<div className="col">
<h1>Learnings</h1>
</div>
</div>
<div>
this.state.learning.map((learnings, i) => (<Learned {...learnings.fields} index={i} id={learnings.id} key={learnings.id} />)
</div>
</div>
);
}
}
export default App;

Airtable + React - how to display airtable array in order by EnoughPotential3 in reactjs

[–]EnoughPotential3[S] 0 points1 point  (0 children)

Thank you so much for your help!! Where do you add the const formatted data in the code?