Preface
...so you're going to have to change the way you think about GN until they add loop nodes. The way we construct most thinkinsg in GN, is using fields (and not so much static values), and the way we go about it is backwards or reverse of the way you are doing it.
Solution Explanation
In your case you want to instance the mesh line and then set the position.
You want to hold the edge position data on the edges even after they are converted into points and instanced on, that way when we make the instances real we can still use the edge data, even though we aren't working with the edges anymore.
solution
The way you do this is by
- capturing the edge vertices positions on the edges (using the capture attribute node. set the capture domain to edge).
- Then you convert it to points (mesh to points node set to edge) ,
- instance the line (on the points, using instance on points node),
- and convert the instances to real geometry (so you can actually manipulation it properly) (using the realize instances node).
- Then use the endpoint selection node together with a switch node (set to vector) to set one end of the curve to the fist vertex position and one to the second vertex position (these positions are the ones you captured).
- This vector is going the be the position (position input) of a set position node.
Alternatively you could use the mesh to points node's position input to set the position of the points to one vertex;
that way you only need to capture one attribute (that of the second vertex position),
as well you wouldn't need to use a switch node, rather you could just use the set position node's selection (with the endpoint selection node).
Here are the nodes:
@lemon 's solution is better for your use case, but this is a good lesson on how GN work.