iamshaunjp / iamshaunjp/Supabase-Tutorial-for-Beginners
Create.js - "Insert" doesn't return 'data'
- Dominant language
- HTML
- Stars
- 118
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
In the Create.js file we find the following code:
```JS
const { data, error } = await supabase
.from('recipes')
.insert([{ title, method, rating }])
if (error) {
console.log(error)
setFormError('Please fill in all the fields correctly.')
}
if (data) {
console.log(data)
setFormError(null)
navigate('/')
}
}
```
Yet `insert` doesn't provide a `data` object (anymore?). Therefore `data`is always `undefined` and the positive if-branch won't run.
## Solution:
In the if-branch simply replace the oc
de like this:
```JS
if (error) {
console.log(error)
setFormError('Please fill in all the fields correctly.')
} else {
setFormError(null)
navigate('/')
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.