How to rotate to mouse.[FIXED]

Im sorry if this is a nooby question but i dont know how to have an object jointed to another on and have that object rotate to the mouse . I only know how to do it not in the Box2D engine. How would i go about doing this in this engine? Thanks guys 😀
There are two ways to do this.

First way is to use a mouseJoint, and attach it to some part of the body you want to rotate. Take a look at this topic: viewtopic.php?f=8&t=2945&p=14552&hilit=flashlight#p14552

Second, you can calculate the angle that your body should be at, and then use SetXForm. Something like:
Code:
var xdiff = body.GetPosition().x - mouseX;
var ydiff = body.GetPosition().y - mouseY;
var newAngle = Math.atan2(ydiff, xdiff);
myBody.SetXForm(body.GetPosition(), newAngle);
Thanks that was really helpful

Original thread: https://box2d.org/forum/viewtopic.php?t=3009