Skip to content

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.

License

Notifications You must be signed in to change notification settings

su14iman/typo3-connector

Repository files navigation

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:

importT3Connectorfrom"@su14iman/typo3-connector";

constconnector=newT3Connector(`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

  • @returnT3Connector

-cached()

to set cache in fetch options

  • @returnT3Connector

-method(method: string)

to set method - GET | POST | PUT | DELETE

  • @returnT3Connector

-data(data: Object)

to set data in fetch options

  • @paramObjectdata
  • @returnT3Connector

-requestParser()

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

  • @returnT3Connector

-fetch<T>(options?: RequestInit)

to fetch data from API

  • @returnT3Connector

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 theMIT License.

About

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.

Topics

Resources

License

Stars

Watchers

Forks