Newcastle United were given an early scare by their League Two opponents at St James’ Park before running out 3-1 winners.