title: Sequelize, Deleting multiple rows with React
body: <p>I'm using React with a Postgres DB with Sequelize.
  within my project, I have a promise that is "suppose" to delete all songs relating to the album, using the the Album.id in my state.</p>
  
  <p>** Instead of deleting the rows of songs relating to the Album, after the delete request in the database, it removes the value of the AlbumId of the song. **</p>
  
  <p>Is there an update I am missing</p>
  
  <p>When I console.log outside of the service and in the promise this.state.Album.id remains the same. 
  It hit's the server with the appropriate number.</p>
  
  <p>This is the function within the React Component
      DeleteAlbum (e) {
          e.preventDefault()</p>
  
  <pre><code>    axios.delete(`${domain}/albums/${this.state.Album.id}`)
      .then((res) =&gt; {
        axios.delete(`${domain}/songs/ByAlbumId/${this.state.Album.id}`)
        .then((res) =&gt; {
          window.location.href = '/#/'
        })
        .catch((error) =&gt; {
          console.log('axios error', error)
        })
      })
      .catch((error) =&gt; {
        console.log('axios error', error)
      })
    }
  </code></pre>
  
  <p>This is the Database to the Songs Route</p>
  
  <pre><code>const express = require('express')
  const router = express.Router()
  const bodyParser = require('body-parser')
  const db = require('./../models')
  const Song = db.Song
  
  router.use(bodyParser.json({ extended: false }))
  
  const exists = (req) =&gt; {
    if (typeof parseInt(req.params.id) === 'number') {
      Album.findOne({
        where: {
          id: req.params.id
        }
      })
      .then((album) =&gt; {
        if (album) {
          return true
        };
        return false
      })
      .catch((err) =&gt; {
        return false
      })
    } else {
      return false
    }
  }
  
  router.delete('/ByAlbumId/:id', function (req, res) {
    Song.destroy({
      where: {
        AlbumId: req.params.id
      }
    })
    .then(function (data) {
      return res.json(data)
    })
    .catch(function (err) {
      return res.json({ error: err})
    })
  })
  
  router.delete('/:id', function (req, res) {
    if (exists) {
      Song.destroy({
        where: {
          id: req.params.id
        }
      })
      .then(function (data) {
        return res.json(data)
      })
      .catch(function (err) {
        return res.json({ error: err})
      })
    } else {
      res.json({success: false})
    }
  })
  </code></pre>
  
  <p>This is the Album Route</p>
  
  <pre><code>const express = require('express')
  const router = express.Router()
  const bodyParser = require('body-parser')
  const db = require('./../models')
  const Album = db.Album
  
  router.use(bodyParser.json({ extended: false }))
  
  const exists = (req) =&gt; {
    if (typeof parseInt(req.params.id) === 'number') {
      Album.findOne({
        where: {
          id: req.params.id
        }
      })
      .then((album) =&gt; {
        if (album) {
          return true
        };
        return false
      })
      .catch((err) =&gt; {
        return false
      })
    } else {
      return false
    }
  }
  
  router.delete('/:id', function (req, res) {
    if (exists) {
      Album.destroy({
        where: {
          id: req.params.id
        }
      })
      .then(function (data) {
        return res.json(data)
      })
      .catch(function (err) {
        return res.json({ error: err})
      })
    } else {
      res.json({success: false})
    }
  })
  </code></pre>
  
  <p>If I place console logs all over the place, the output is what I expect it to be. There's is just something going wrong with Deleting two songs from my app. I can delete multiple songs if I hit the server directly with postman</p>
  
  <p>Any idea?</p>