1.0.5 • Published 12 months ago

@su14iman/typo3-connector v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

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

  • @return T3Connector

- cached()

to set cache in fetch options

  • @return T3Connector

- method(method: string)

to set method - GET | POST | PUT | DELETE

  • @return T3Connector

- data(data: Object)

to set data in fetch options

  • @param Object data
  • @return T3Connector

- requestParser()

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

  • @return T3Connector

- fetch<T>(options?: RequestInit)

to fetch data from API

  • @return T3Connector

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.

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago