typo3-connector

The T3Connector class is designed to facilitate making HTTP requests to an API. It encapsulates the functionality needed to build and execute these requests in a fluent and flexible manner.

Requirements

How to use:

import T3Connector from "@su14iman/typo3-connector";

const connector = new T3Connector(`https://headless-typo3.typo3.su14iman.local`);

connector.query({
    path: "/"
})
.method("GET")
.cached()
.fetch<T3ContentElements[]>()
.then((res) => {
    console.log(res['id']);
});

Functions

- query({ path, uri, options } : { path?: string, uri?: string, options?: RequestInit })

to start new query and clear old path and old uri

- cached()

to set cache in fetch options

- method(method: string)

to set method - GET | POST | PUT | DELETE

- data(data: Object)

to set data in fetch options

- requestParser()

to parse request, but you do not need to add it to the query, it was added to be used with tests

- fetch<T>(options?: RequestInit)

to fetch data from API

Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -am 'Add your feature')
  4. Push to the branch (git push origin feature/your-feature)
  5. Create a new Pull Request

License

This project is licensed under the MIT License.