You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I will try to create a todo API using Vania, but I can't I will install Vania on my local computer but I can do it. can you Help me create a todo API ,
i will try this but it's not work
import 'package:vania/vania.dart'
class Todo extends Model {
String title;
bool completed;
Todo({this.title, this.completed = false});
}
class TodoController extends ResourceController {
@Operation.get()
Future<Response> getAllTodos() async {
List<Todo> todos = await Todo.query().fetch();
return Response.ok(todos);
}
@Operation.post()
Future<Response> createTodo() async {
Todo todo = Todo()..read(await request.body.decode());
await todo.save();
return Response.ok(todo);
}
}
class TodoApiChannel extends ApplicationChannel {
ManagedContext context;
@override
Future prepare() async {
context = ManagedContext(...); // setup your database connection details here
}
@override
Controller get entryPoint {
final router = Router();
router.route('/todos/[:id]')
.link(() => TodoController());
return router;
}
}
Future main() async => runApp(TodoApiChannel());
The text was updated successfully, but these errors were encountered:
Hello Sir,
I will try to create a todo API using Vania, but I can't I will install Vania on my local computer but I can do it. can you Help me create a todo API ,
i will try this but it's not work
The text was updated successfully, but these errors were encountered: