Skip to content

I'm having trouble creating a custom endpoint. #2

Description

@DerekSMorin

I was able to get the rest api up and running and the following url works in my browser:
http://127.0.0.1:1781/api/

If I add a custom endpoint, would it show up in that list of apis?

I tried making my settings:

"rest.api": {
    "autoStart": true,
    "openInBrowser": true,
    "port": 1781,
    
    "endpoints": {
        "myendpoint": {
            "script": "./my-endpoint.js",
            "options": "Hello!"
        }
    }
},

And saving the example script you gave here: ( in the same folder as settings.json )

image

Should I be able to excecute it with:

http://127.0.0.1:1781/api/myendpoint

I'm not sure how I would debug this, or if it is possible my .js file is in the wrong spot, or invalid, or if I need special settings to allow executing a custom endpoint.

I will want to create a few custom endpoints like:

  1. get current line number ( where cursor position is )
  2. get current line text
  3. get current file name ( api/editor seems like a start but I think it might crash if the content of the file is too large )

I'm interested in learning how to write all of these but I think I need to get my "hello world" example going first :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions