todolist-api

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2018 License: MIT Imports: 5 Imported by: 0

README

A Todo list API build with Golang and Sqlite3

Build

go build

Run

./todolist-api

API

Struct

type Todo struct {
	ID      uint   `json:"id"`
	Content string `json:"content"`
}

Access with Axios and jQuery

// Axios
axios.post('http://localhost:8888/todo/create', {content:"buy a book"}).then(resp => console.log(resp.data));
axios.get('http://localhost:8888/todos').then(resp => console.log(resp.data));

// jQuery
$.ajax({
  url: 'http://localhost:8888/todo/create',
  method: 'POST',
  contentType: 'application/json',
  data: JSON.stringify({content:"buy a book"}),
  success: function (todo) {
    console.log(todo)
  },
  error: function (xhr, status) {
    console.error("error");
  }
});

$.ajax({
  url: "http://localhost:8888/todos",
  type: "GET",
  crossDomain: true,
  dataType: "json",
  success: function (todos) {
    console.log(todos)
  },
  error: function (xhr, status) {
    console.error("error");
  }
});

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL