fictionco / fiction

(Public Release Summer 2024) Personal Marketing Platform. A powerful platform for your online identity.

Home Page:https://www.fiction.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addContentRoute doesent work

dselcan2 opened this issue · comments

Reason for this issue
I was trying to add a custom endpoint in my factor app but was unable to do so. I've looked at the documentation available assessing, that addContentRoute should do what I want, but I couldn't get it to work. Out of frustration I cloned the factor example repo and tried there to see how/if it works there and upon trying to visit the "/page" endpoint I got a 404, which led me to the conclusion that addContentRoute does not work (or at least the way I am trying to use it in).

Steps to Reproduce
clone the https://github.com/fiction-com/factor-example repo build and visit the /page endpoint.

@dselcan2 the example app was out of date, we finalized the APIs and so on January 1 when we went to 1.0.

Anyway, I've updated the example app and it's all working now. Give it a shot.

TWO IMPORTANT THINGS

  1. Make sure the main files are getting loaded. For this you need load in your package.json
  2. Make sure you are importing functions from the right place (this was the problem with the example app)... (Using TypeScript helps with this as it will error if it can't find the function)
{
  "name": "factor-example",
  "factor": {
    "load": [
      "app",
      "server"
    ]
  },
  "dependencies": {
    "@factor/core": "^1.5.0"
  }
}
import { addContentRoute } from "@factor/api";

addContentRoute({
  path: "/",
  component: () => import("./view-home.vue")
});

addContentRoute({
  path: "/page",
  component: () => import("./view-page.vue")
});