Fix bad API calls in JS scripts