Debug Creating a link on Console

On my Webpage i already have 2 nodes present. How can i test creating a link(one way arrow) from my browser console.
Could anyone suggest similar to what is present at below link

If you have references to the two Nodes that you want to connect, and if your model is a GraphLinksModel, then something like this might work:

myDiagram.model.commit(function(m) {
  m.addLinkData({ from: node1.key, to: node2.key });

That makes some assumptions about the nature of your nodes (i.e. just a single port for each node) and the properties on the link data used to refer to the nodes (i.e. “from” and “to”). And of course your app might expect more data properties on the link data – all such properties are application-specific.

Thanks walter! Your solution helped me draw the link. But i and not able to save my Diagram later and i get below error on console:

go.js?_dc=20200515001523:14 Uncaught Error: Diagram.currentTool value is not an instance of Tool: LinkLabelDragging Tool

Looks like i am half way through. Need a little more help to understand which exact tool to use or basically call as part of js function.

I have no idea – look carefully at all places in code that you are using that sets Diagram.currentTool.

And I have no idea of how this error could possibly happen when trying to save a diagram model, the first step of which is usually getting a string form of the model by calling myDiagram.model.toJson(). Then you just need to get that string and any other state that you care about to the server.

Thanks walter . I will check.