Gathering detailed insights and metrics for @justeat/f-http
Gathering detailed insights and metrics for @justeat/f-http
Gathering detailed insights and metrics for @justeat/f-http
Gathering detailed insights and metrics for @justeat/f-http
Public monorepo of tools, services and atomic UI components within the fozzie ecosystem
npm install @justeat/f-http
Typescript
Module System
Min. Node Version
Node Version
NPM Version
73.4
Supply Chain
98.6
Quality
82.8
Maintenance
50
Vulnerability
100
License
core-analytics@1.21.0
Updated on Jul 11, 2023
f-header@v10.15.0
Updated on Jun 26, 2023
f-registration@3.8.0
Updated on Oct 28, 2022
f-registration@3.7.2
Updated on Oct 21, 2022
f-error-message@2.3.0
Updated on Oct 03, 2022
f-header@10.7.0
Updated on Sep 13, 2022
JavaScript (73.54%)
Vue (17.7%)
SCSS (5.66%)
MDX (2.88%)
HTML (0.2%)
CSS (0.01%)
Handlebars (0.01%)
Total Downloads
13,610
Last Day
1
Last Week
11
Last Month
78
Last Year
2,372
NOASSERTION License
16 Stars
1,973 Commits
37 Forks
32 Watchers
272 Branches
76 Contributors
Updated on May 07, 2025
Minified
Minified + Gzipped
Latest Version
1.1.1
Package Id
@justeat/f-http@1.1.1
Unpacked Size
407.12 kB
Size
110.07 kB
File Count
8
NPM Version
lerna/3.22.1/node@v20.12.2+x64 (linux)
Node Version
20.12.2
Published on
Apr 29, 2024
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
0%
11
Compared to previous week
Last Month
-25%
78
Compared to previous month
Last Year
254.6%
2,372
Compared to previous year
2
Javascript HTTP client for interacting with restful services
This package exposes methods for interacting with restful services, it may abstract any number of popular NPM packages which provide the ability to perform GET, PUT, POST, PATH, DELETE requests; while also adding some additional benefits.
Install the module using npm or Yarn
1yarn add @justeat/f-http
Ideally the package should be initialised by your website and the httpClient placed in context or a prototype, rather than initialising it in each individual component or every time you make a request.
httpClient
1import httpModule from '@justeat/f-http'; 2 3const options = { // Options are described later 4 baseUrl: 'https://jsonplaceholder.typicode.com' 5}; 6 7// Optional: Implement wrapper using cookie tech you have available 8// Enables conversation ID to be automatically provided with requests 9const getCookieFunction = cookieName => app.$cookies.get(cookieName); 10 11const httpClient = new httpModule.CreateClient(options, getCookieFunction); 12 13// WHEN: Using a Nuxt Plugin 14inject('http', httpClient); 15 16// WHEN: Using Vue CLI 17Vue.prototype.$http = httpClient;
Recommended: Using the prototype (Vue) or context (Nuxt). You can access $http in components, or anywhere the context is available including vuex modules.
1export default { 2 data () { 3 return { 4 apiResult: null 5 } 6 }, 7 async mounted () { 8 this.apiResult = await this.$http.get('/todos/1'); 9 } 10}
If you would rather create the HTTPClient when you use it, that's fine too; it just means it can't be reused as easily and you will need to filter the configuration options down to the component.
1export default { 2 async mounted () { 3 const configuration = { // Options are described later 4 baseUrl: 'https://jsonplaceholder.typicode.com' 5 }; 6 7 const httpClient = new httpModule.CreateClient(configuration); 8 9 const result = await httpClient.get('/todos/1'); 10 } 11}
You can globally set the authorisation token so that all requests provide it
1// Some event happened that means we now have a token 2export default { 3 mounted () { 4 this.$http.setAuthorisationToken('my token'); 5 } 6}
Because $http exists in context, it should be really easy to mock it in any way you want. Check out the example below
1const wrapper = mount(MyComponent, { 2 mocks: { 3 $http: { 4 get: jest.fn() 5 } 6 } 7});
The module exposes a way to create a MockClient, so you can mock the underlying API with pre-configured responses.
1import { httpVerbs, MockFactory, CreateClient } from '@justeat/f-http'; 2 3const mockFactory = new MockFactory(); 4const httpClient = new CreateClient(); 5 6const wrapper = mount(MyComponent, { 7 mocks: { 8 $http: httpClient 9 } 10}); 11 12// Reset all previously configured responses 13mockFactory.reset(); 14 15// Setup a fake response 16mockFactory.setupMockResponse(httpVerbs.POST, '/URL', REQUEST_DATA, 201);
None of these parameters are required, but using them enables you to customise your http client
Option | Description | Type | Default |
---|---|---|---|
options | An object containing options you wish to override (see below) | object | {} |
getCookieFunction | Wrapper function providing ability to read cookies | function | null |
statisticsClient | Instance of f-statistics to capture dependency timings | object | null |
All options are optional, you don't need to specify any overrides if you are happy with the default values
Option | Description | Type | Default |
---|---|---|---|
baseUrl | Ensure all requests from this client use a relative url | string | '' |
timeout | How long each request takes to timeout | number | 10000 |
errorCallback | A function you can use to globally handle errors (accepts error object) | function | null |
contentType | Specify a value for the content type header | string | 'application/json' |
These are all of the methods exposed by the httpClient
Method | Description | Parameters |
---|---|---|
get | GET a resource | resource URL [string], headers [array] |
post | POST a resource | resource URL [string], body [object], headers [array] |
put | PUT a resource | resource URL [string], body [object], headers [array] |
patch | PATCH a resource | resource URL [string], body [object], headers [array] |
delete | DELETE a resource | resource URL [string], headers [array] |
setAuthorisationToken | Set the authorisation token for all requests | authorisationToken [string] |
readConfiguration | Returns the provided options | None |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
92 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More