Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring default header in fetch.js in Service #1273

Merged

Conversation

yashkohli88
Copy link
Contributor

@yashkohli88 yashkohli88 commented Jan 15, 2025

Overview

This pull request is aimed at refactoring the fetch.js file to introduce a defaultHeader variable. This variable will be used as the default header across all Axios requests within the service repository, providing a more streamlined and maintainable approach to request configuration.

Tasks Completed

  1. Introduction of defaultHeader:
  • Implemented a defaultHeader variable in the fetch.js file to serve as a default header. This header is now included in the Axios global configuration to ensure it is applied to every request automatically.
  1. User-Agent Header Replacement:
  • - Replaced instances of the withDefaults function across the codebase with callFetch. This change enables to control all the default headers from a centralized file.
  • - Updated various parts of the service repository to replace individual user-agent header entries with the global defaultHeader, promoting uniformity and reducing the risk of errors or omissions.
  1. Test Case Updates:
  • - Modified test cases to incorporate the global defaultHeader, ensuring that the tests remain accurate and reflective of the new header setup.
  • - New unit test cases are also added to increase test coverage for the changes.
  • - Origins API test integration ran on the new code to ensure the regression test cases are working fine.

This PR is related to #1090

@qtomlinson qtomlinson merged commit ef000e6 into clearlydefined:master Jan 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants