So this is what I am using to get my data from airtable
import axios from "axios"
formSubmitHandler = e => {
axios
.get(
"https://api.airtable.com/v0/" + app_id + "/" + view,
{ headers: { Authorization: "Bearer " + app_key } },
)
.then(resp => console.log(resp))
.catch(error => console.log(error))
e.preventDefault()
}
This works very well, however when I try to post something into the same table and now using this:
formSubmitHandler = e => {
const { name, email } = this.state
const data = {
"records": [
{
"fields": {
"Name": name,
"Email": email,
}
}
]
}
console.log(data)
axios
.post(
"https://api.airtable.com/v0/" + app_id + "/" + view,
{ headers: { Authorization: "Bearer " + app_key } },
data
)
.then(resp => console.log(resp))
.catch(error => console.log(error))
e.preventDefault()
}
It doesn’t work and I always get ERROR 401, and that shouldn’t be the case as I already managed to get the information out of my airtable.
Any ideas why this is happening?
Thank you,
Tiago
