cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Building Neo4j Applications with Node.js

Hello

I'm facing some issue regarding neoflix-ui app. Method to remove a movie from my favorite list returns an error `` TypeError: service.remove is not a function`

The code in favorite.service.js file seems ok, I don't see where is the problem:

``

// tag::Remove movie from the list[]
async remove(userId, movieId) {
// Open a new Session
const session = this.driver.session()

// Create HAS_FAVORITE relationship within a Write Transaction
const res = await session.executeWrite(
tx => tx.run(
`
MATCH (u:User {userId: $userId})-[r:HAS_FAVORITE]->(m:Movie {tmdbId: $movieId})

DELETE r

RETURN m {
.*,
favorite: false
} AS movie
`,
{ userId, movieId, }
)
)

// Throw an error if the user or movie could not be found
if ( res.records.length === 0 ) {
throw new NotFoundError(
`Could not remove favorite relationship between User ${userId} and Movie ${movieId}`
)
}

// Close the session
await session.close()

// Return movie details and `favorite` property
const [ first ] = res.records
const movie = first.get('movie')

return toNativeTypes(movie)
}

// end::Remove movie from the list[]
 
Any advice?
Tks
2 REPLIES 2

William_Lyon
Graph Fellow

Hi @darciosavilela - could you share the stack trace in the error message? That will help troubleshoot. 

Tks William, but I got the error fixed. Just close and open my vs code again and could run properly.

tks