├── LICENSE
├── README.md
├── api_course.json
├── courses.json
├── node_modules
├── axios
│ ├── CHANGELOG.md
│ ├── LICENSE
│ ├── README.md
│ ├── UPGRADE_GUIDE.md
│ ├── dist
│ │ ├── axios.js
│ │ ├── axios.map
│ │ ├── axios.min.js
│ │ └── axios.min.map
│ ├── index.d.ts
│ ├── index.js
│ ├── lib
│ │ ├── adapters
│ │ │ ├── README.md
│ │ │ ├── http.js
│ │ │ └── xhr.js
│ │ ├── axios.js
│ │ ├── cancel
│ │ │ ├── Cancel.js
│ │ │ ├── CancelToken.js
│ │ │ └── isCancel.js
│ │ ├── core
│ │ │ ├── Axios.js
│ │ │ ├── InterceptorManager.js
│ │ │ ├── README.md
│ │ │ ├── buildFullPath.js
│ │ │ ├── createError.js
│ │ │ ├── dispatchRequest.js
│ │ │ ├── enhanceError.js
│ │ │ ├── mergeConfig.js
│ │ │ ├── settle.js
│ │ │ └── transformData.js
│ │ ├── defaults.js
│ │ ├── helpers
│ │ │ ├── README.md
│ │ │ ├── bind.js
│ │ │ ├── buildURL.js
│ │ │ ├── combineURLs.js
│ │ │ ├── cookies.js
│ │ │ ├── deprecatedMethod.js
│ │ │ ├── isAbsoluteURL.js
│ │ │ ├── isAxiosError.js
│ │ │ ├── isURLSameOrigin.js
│ │ │ ├── normalizeHeaderName.js
│ │ │ ├── parseHeaders.js
│ │ │ └── spread.js
│ │ └── utils.js
│ └── package.json
├── follow-redirects
│ ├── LICENSE
│ ├── README.md
│ ├── debug.js
│ ├── http.js
│ ├── https.js
│ ├── index.js
│ └── package.json
└── readline-sync
│ ├── LICENSE
│ ├── README-Deprecated.md
│ ├── README.md
│ ├── lib
│ ├── encrypt.js
│ ├── read.cs.js
│ ├── read.ps1
│ ├── read.sh
│ └── readline-sync.js
│ └── package.json
├── package-lock.json
└── requests_api.js
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 anandpatel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Requests-API-in-js
2 |
3 | SARAL is the eLearning platform of NavGurukul, which is available on website http://saral.navgurukul.org. I have created a CLI based app where users can access the content of saral using the terminal.
4 |
5 | ## Axios
6 |
7 | Axios is a promise-based HTTP client that works both in the browser and in a node.js environment. It basically provides a single API for dealing with XMLHttpRequests and node's http interface.
8 |
9 | ## Requirements and Installation
10 |
11 | If you're using Windows, go through the official site of Nodejs to install it. For Linux-based OS, proceed with the following commands on your terminal.
12 |
13 | ```
14 | sudo apt-get install npm
15 | npm install axios --save
16 | ```
17 | ou do also need to install fs (File System) to access physical file system, like reading and writing files. To install run the given commands in your terminal.
18 |
19 | `npm install fs --save`
20 |
21 | To run your code, first open your server port using node `file_name.js` in your working directory in terminal. And, then you can apply the basic CRUD operations.
22 |
--------------------------------------------------------------------------------
/api_course.json:
--------------------------------------------------------------------------------
1 | {"availableCourses":[{"id":14,"name":"GIT101 - Learning GIT","type":"js","logo":"https://tcrn.ch/2Kd0xvh","shortDescription":"Learning Basics of using GIT","sequenceNum":7},{"id":15,"name":"Introduction to HTML","type":"html","logo":"https://bit.ly/2FufxWZ","shortDescription":"Learn how to use HTML to build simple web pages :)","sequenceNum":11},{"id":16,"name":"Introduction to CSS","type":"html","logo":"https://bit.ly/2BfcwWh","shortDescription":"Learn how to use CSS to add styles to simple web pages :)","sequenceNum":12},{"id":18,"name":"Basics of Programming using Python","type":"python","logo":"https://bit.ly/1h4FwSY","shortDescription":"We will learn the basics of programming using this course.","sequenceNum":27},{"id":22,"name":"Getting Started","type":"python","logo":"https://bit.ly/2A2rddz","shortDescription":"We will learn how to spend your time effectively at NavGurukul. All new students must go through this course.","sequenceNum":41},{"id":23,"name":"Samvaad - Beginner","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Topics for English conversation among students","sequenceNum":5},{"id":24,"name":"Samvaad - Intermediate","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"English Conversation Cards","sequenceNum":14},{"id":30,"name":"Learn 3000 English Words","type":"html","logo":"https://bit.ly/2QbmyjG","shortDescription":"Build your english vocabulary by learning these 3000 words","sequenceNum":17},{"id":32,"name":"Android - Learn Android","type":"html","logo":"https://bit.ly/2Bez35n","shortDescription":"Chalo bhai, Android seekhte hai!","sequenceNum":20},{"id":33,"name":"Hackathon - Dry Run on a Dry Day","type":"html","logo":"https://bit.ly/2PAmJoV","shortDescription":"Isse aap program ka dry run ke through program ka control flow bananana seekhoge.","sequenceNum":21},{"id":34,"name":"English - Beginner","type":"js","logo":"https://bit.ly/2zp7YLR","shortDescription":"Learn English Basics","sequenceNum":22},{"id":36,"name":"Reading Comprehension","type":"html","logo":"https://bit.ly/2DLPMiW","shortDescription":"Topics for English conversation among students","sequenceNum":25},{"id":37,"name":"English - Intermediate","type":"html","logo":"https://bit.ly/2zp7YLR","shortDescription":"English learning for intermediate level","sequenceNum":23},{"id":40,"name":"Diwali Projects","type":"html","logo":"https://bit.ly/2Dsw8Yw","shortDescription":"Diwali Par Chutti ke liye Projects","sequenceNum":26},{"id":41,"name":"Programming Exercises (AMAR)","type":"html","logo":"https://bit.ly/2A2uqd7","shortDescription":"Programming Exercise Course.","sequenceNum":19},{"id":42,"name":"Samvaad - Learning through dialogue!","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Learn English with one-on-one dialogues and reflecting on various important topics","sequenceNum":3},{"id":44,"name":"Manthan","type":"html","logo":"https://bit.ly/2OPsppK","shortDescription":"Manthan Opportunities and Experiences","sequenceNum":1},{"id":49,"name":"Problem Solving 101","type":"html","logo":"https://bit.ly/2A2uqd7","shortDescription":"Some great problem solving challenges to keep you awake.","sequenceNum":5},{"id":50,"name":"Bas Ek Galti!","type":"html","logo":"https://bit.ly/2QQFd11","shortDescription":"Learning how to fix python errors","sequenceNum":6},{"id":51,"name":"Professional Email Writing","type":"html","logo":"http://bit.do/pyON","shortDescription":"You will learn how to write professional emails in this course.","sequenceNum":2},{"id":53,"name":"Understanding programming through recursion","type":"html","logo":"http://bit.do/recursion-png","shortDescription":"Iss course ko hum use kar kar recursions aur programming ki depth mei jayenge.","sequenceNum":8},{"id":55,"name":"NavGurukul's Constitution - English","type":"html","logo":"https://bit.ly/2FqFR4k","shortDescription":"We will learn about the Constitution of NavGurukul.","sequenceNum":10},{"id":56,"name":"Soch Rahe Hain","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Important habits and tools","sequenceNum":11},{"id":58,"name":"Hangman","type":"html","logo":"http://bit.do/hangman-png","shortDescription":"Iss game par code kar kar hume relatively bade programs likhna seekhenge.","sequenceNum":12},{"id":59,"name":"Kuch Baatein (Samvaad) - SV101","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Let's start talking in English with the help of these very simple topics","sequenceNum":13},{"id":60,"name":"Let's talk Technology (Samvaad) - SV201","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Let's talk on various technology topics to improve our understanding of Technology as well as English","sequenceNum":14},{"id":61,"name":"Let's talk Technology (Samvaad) - SV301","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Let's talk on various technology topics to improve our understanding of Technology as well as English","sequenceNum":15},{"id":62,"name":"Music Angrezi - MS101","type":"html","logo":"https://goo.gl/ctGhRD","shortDescription":"Learn English with some nice music :-)","sequenceNum":16},{"id":63,"name":"Linux Use Karna Seekhein","type":"html","logo":"http://google.com","shortDescription":"Linux kaise use karna hai, iss course ko use kar kar seekhein.","sequenceNum":17},{"id":64,"name":"Implementing Database - Python","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Iss course mei hum Python use kar kar apna ek chota sa database banayenge","sequenceNum":18},{"id":65,"name":"Kaise Effectively Mentor karein?","type":"html","logo":"https://bit.ly/2GavrpP","shortDescription":"Iss course mei hum kaise effectively mentor kar sakte hai, yeh seekhenge","sequenceNum":28},{"id":66,"name":"Technical Readings - 101","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Iss Course ko aap use kar kar English mei important Technology Concepts padh kar samajh sakte hai","sequenceNum":29},{"id":67,"name":"Technical Readings - 201","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Iss Course ko aap use kar kar English mei important Technology Concepts padh kar samajh sakte hai","sequenceNum":30},{"id":68,"name":"Edge cases - Python","type":"html","logo":"https://bit.ly/1h4FwSY","shortDescription":"Iss course mei hum apne programs mai edge cases ke baare mai jaanege or unhe kaise handle kare ye seekhenge","sequenceNum":31},{"id":69,"name":"English Movies","type":"html","logo":"https://bit.ly/2A2uqd7","shortDescription":"Find list of English movies to watch","sequenceNum":32},{"id":70,"name":"NavGurukul ka Constitution - Hindi","type":"html","logo":"https://bit.ly/2FqFR4k","shortDescription":"We will learn about the Constitution of NavGurukul.","sequenceNum":33},{"id":71,"name":"Non-Technical Readings - 201","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Iss Course ko aap use kar kar English mei important Concepts padh kar samajh sakte hai","sequenceNum":34},{"id":72,"name":"Grammar 101","type":"html","logo":"https://bit.ly/2zp7YLR","shortDescription":"English Grammar","sequenceNum":35},{"id":73,"name":"Grammar 201","type":"html","logo":"https://bit.ly/2zp7YLR","shortDescription":"English Grammar","sequenceNum":36},{"id":74,"name":"Implementing PickleDB - DB - Part I","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Iss course mei hum Python use kar kar apna ek chota sa database banayenge","sequenceNum":37},{"id":75,"name":"Requests - Using APIs in Python","type":"html","logo":"https://bit.ly/2PzSPkJ","shortDescription":"Python mei API kaise use karte hai, iss course se seekhein","sequenceNum":38},{"id":76,"name":"Web Scraping 101","type":"html","logo":"http://bit.ly/2LQnUeX","shortDescription":"Web Scraping can help us get a lot of interesting data from the","sequenceNum":39},{"id":77,"name":"NavGurukul Learning Framework","type":"js","logo":"https://bit.ly/2Frmrw7","shortDescription":"Understanding framework of how NavGurukul Works","sequenceNum":40},{"id":78,"name":"English 201","type":"html","logo":"https://bit.ly/2PAmJoV","shortDescription":"English basics","sequenceNum":42},{"id":79,"name":"English 101 - Let's Begin","type":"html","logo":"https://bit.ly/2PAmJoV","shortDescription":"English basics","sequenceNum":43},{"id":80,"name":"Lists 101 (Using Python)","type":"html","logo":"https://cdn1.iconfinder.com/data/icons/it-terms/512/loop-512.png","shortDescription":"Lists ko thoda depth mein samajhte hain.","sequenceNum":44},{"id":81,"name":"English 401","type":"html","logo":"https://bit.ly/2zp7YLR","shortDescription":"English learning","sequenceNum":45},{"id":82,"name":"English 301","type":"html","logo":"https://bit.ly/2PAmJoV","shortDescription":"English basics","sequenceNum":46},{"id":83,"name":"Loops 101 (Using Python)","type":"html","logo":"https://cdn1.iconfinder.com/data/icons/it-terms/512/loop-512.png","shortDescription":"Loops ko thoda depth mein samajhte hain.","sequenceNum":47},{"id":84,"name":"English 501","type":"html","logo":"https://bit.ly/2zp7YLR","shortDescription":"English learning","sequenceNum":48},{"id":85,"name":"Seva","type":"html","logo":"https://bit.ly/2TlR0WN","shortDescription":"NavGurukul ke 'Seva' model ke baare me jaanenge.","sequenceNum":49},{"id":86,"name":"English 601","type":"html","logo":"https://bit.ly/2zp7YLR","shortDescription":"English learning","sequenceNum":50},{"id":87,"name":"English 701","type":"html","logo":"https://bit.ly/2zp7YLR","shortDescription":"English learning","sequenceNum":51}]}
--------------------------------------------------------------------------------
/courses.json:
--------------------------------------------------------------------------------
1 | {"enrolledCourses":[],"availableCourses":[{"id":"53","name":"Understanding programming through recursion","type":"html","logo":"http://bit.do/recursion-png","short_description":"Iss course ko hum use kar kar recursions aur programming ki depth mei jayenge."},{"id":"70","name":"NavGurukul ka Constitution - Hindi","type":"html","logo":"https://bit.ly/2FqFR4k","short_description":"We will learn about the Constitution of NavGurukul."},{"id":"69","name":"English Movies","type":"html","logo":"https://bit.ly/2A2uqd7","short_description":"Find list of English movies to watch"},{"id":"49","name":"Problem Solving 101","type":"html","logo":"https://bit.ly/2A2uqd7","short_description":"Some great problem solving challenges to keep you awake."},{"id":"84","name":"English 501","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"English learning"},{"id":"15","name":"Introduction to HTML","type":"html","logo":"https://bit.ly/2FufxWZ","short_description":"Learn how to use HTML to build simple web pages :)"},{"id":"44","name":"Manthan","type":"html","logo":"https://bit.ly/2OPsppK","short_description":"Manthan Opportunities and Experiences"},{"id":"71","name":"Non-Technical Readings - 201","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Iss Course ko aap use kar kar English mei important Concepts padh kar samajh sakte hai"},{"id":"41","name":"Programming Exercises (AMAR)","type":"html","logo":"https://bit.ly/2A2uqd7","short_description":"Programming Exercise Course."},{"id":"50","name":"Bas Ek Galti!","type":"html","logo":"https://bit.ly/2QQFd11","short_description":"Learning how to fix python errors"},{"id":"80","name":"Lists 101 (Using Python)","type":"html","logo":"https://cdn1.iconfinder.com/data/icons/it-terms/512/loop-512.png","short_description":"Lists ko thoda depth mein samajhte hain."},{"id":"59","name":"Kuch Baatein (Samvaad) - SV101","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Let's start talking in English with the help of these very simple topics"},{"id":"22","name":"Getting Started","type":"html","logo":"https://bit.ly/2A2rddz","short_description":"We will learn how to spend your time effectively at NavGurukul. All new students must go through this course."},{"id":"81","name":"English 401","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"English learning"},{"id":"42","name":"Samvaad - Learning through dialogue!","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Learn English with one-on-one dialogues and reflecting on various important topics"},{"id":"55","name":"NavGurukul's Constitution - English","type":"html","logo":"https://bit.ly/2FqFR4k","short_description":"We will learn about the Constitution of NavGurukul."},{"id":"58","name":"Hangman","type":"html","logo":"http://bit.do/hangman-png","short_description":"Iss game par code kar kar hume relatively bade programs likhna seekhenge."},{"id":"68","name":"Edge cases - Python","type":"html","logo":"https://bit.ly/1h4FwSY","short_description":"Iss course mei hum apne programs mai edge cases ke baare mai jaanege or unhe kaise handle kare ye seekhenge"},{"id":"30","name":"Learn 3000 English Words","type":"html","logo":"https://bit.ly/2QbmyjG","short_description":"Build your english vocabulary by learning these 3000 words"},{"id":"79","name":"English 101 - Let's Begin","type":"html","logo":"https://bit.ly/2PAmJoV","short_description":"English basics"},{"id":"16","name":"Introduction to CSS","type":"html","logo":"https://bit.ly/2BfcwWh","short_description":"Learn how to use CSS to add styles to simple web pages :)"},{"id":"76","name":"Web Scraping 101","type":"html","logo":"http://bit.ly/2LQnUeX","short_description":"Web Scraping can help us get a lot of interesting data from the"},{"id":"66","name":"Technical Readings - 101","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Iss Course ko aap use kar kar English mei important Technology Concepts padh kar samajh sakte hai"},{"id":"63","name":"Linux Use Karna Seekhein","type":"html","logo":"http://google.com","short_description":"Linux kaise use karna hai, iss course ko use kar kar seekhein."},{"id":"65","name":"Kaise Effectively Mentor karein?","type":"html","logo":"https://bit.ly/2GavrpP","short_description":"Iss course mei hum kaise effectively mentor kar sakte hai, yeh seekhenge"},{"id":"61","name":"Let's talk Technology (Samvaad) - SV301","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Let's talk on various technology topics to improve our understanding of Technology as well as English"},{"id":"33","name":"Hackathon - Dry Run on a Dry Day","type":"html","logo":"https://bit.ly/2PAmJoV","short_description":"Isse aap program ka dry run ke through program ka control flow bananana seekhoge."},{"id":"75","name":"Requests - Using APIs in Python","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Python mei API kaise use karte hai, iss course se seekhein"},{"id":"32","name":"Android - Learn Android","type":"html","logo":"https://bit.ly/2Bez35n","short_description":"Chalo bhai, Android seekhte hai!"},{"id":"83","name":"Loops 101 (Using Python)","type":"html","logo":"https://cdn1.iconfinder.com/data/icons/it-terms/512/loop-512.png","short_description":"Loops ko thoda depth mein samajhte hain."},{"id":"62","name":"Music Angrezi - MS101","type":"html","logo":"https://goo.gl/ctGhRD","short_description":"Learn English with some nice music :-)"},{"id":"24","name":"Samvaad - Intermediate","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"English Conversation Cards"},{"id":"56","name":"Soch Rahe Hain","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Important habits and tools"},{"id":"74","name":"Implementing PickleDB - DB - Part I","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Iss course mei hum Python use kar kar apna ek chota sa database banayenge"},{"id":"77","name":"NavGurukul Learning Framework","type":"html","logo":"https://bit.ly/2Frmrw7","short_description":"Understanding framework of how NavGurukul Works"},{"id":"78","name":"English 201","type":"html","logo":"https://bit.ly/2PAmJoV","short_description":"English basics"},{"id":"72","name":"Grammar 101","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"English Grammar"},{"id":"34","name":"English - Beginner","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"Learn English Basics"},{"id":"73","name":"Grammar 201","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"English Grammar"},{"id":"36","name":"Reading Comprehension","type":"html","logo":"https://bit.ly/2DLPMiW","short_description":"Topics for English conversation among students"},{"id":"82","name":"English 301","type":"html","logo":"https://bit.ly/2PAmJoV","short_description":"English basics"},{"id":"51","name":"Professional Email Writing","type":"html","logo":"http://bit.do/pyON","short_description":"You will learn how to write professional emails in this course."},{"id":"90","name":"Hackthon Projects","type":"html","logo":"https://www.unleashedsoftware.com/assets/uploads/2017/06/hackathon-logo.png","short_description":"Hackthon ke leye kuch Projects"},{"id":"117","name":"Date Types","type":"html","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Iss topic mai hum Data Type ke bare mai janege"},{"id":"114","name":"Functions","type":"html","logo":"https://raw.githubusercontent.com/navgurukul/newton/master/functions/assets/function_defn_inst_1.png","short_description":"Iss topic mai hum functions ke bare mai janege"},{"id":"118","name":"English - Intermediate","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"English learning for intermediate level"},{"id":"119","name":"Let's talk Technology (Samvaad) - SV201","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"Let's talk on various technology topics to improve our understanding of Technology as well as English"},{"id":"101","name":"Introduction To Python","type":"html","logo":"https://bit.ly/1h4FwSY","short_description":"Iss topic mai hum python ka Introduction ke bare mai janege"},{"id":"87","name":"English 701","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"English learning"},{"id":"89","name":"Interview Preparation","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"In this course we will learn advance topics which are required in interviews."},{"id":"92","name":"Maths - hi toh hai yaar! MAT101","type":"html","logo":"https://i.ibb.co/DMQXftx/Maths.png","short_description":"Iss course mei hum apne programs mai edge cases ke baare mai jaanege or unhe kaise handle kare ye seekhenge"},{"id":"95","name":"GIT101 - Learning GIT","type":"html","logo":"https://tcrn.ch/2Kd0xvh","short_description":"Learning Basics of using GIT"},{"id":"88","name":"JavaScript 101","type":"html","logo":"https://bit.ly/2S2Y1un","short_description":"We will learn basics of programming using JavaScript in this course."},{"id":"96","name":"Hackathon Projects","type":"html","logo":"https://www.unleashedsoftware.com/assets/uploads/2017/06/hackathon-logo.png","short_description":"Hackthon ke leye kuch Projects"},{"id":"86","name":"English 601","type":"html","logo":"https://bit.ly/2zp7YLR","short_description":"English learning"},{"id":"97","name":"Introduction to Javascript","type":"html","logo":"https://bit.ly/2S2Y1un","short_description":"Hindi Tutorials to learn to write code in javascript"},{"id":"91","name":"Non-violent Communication","type":"html","logo":"https://bit.ly/2PzSPkJ","short_description":"In this course we will learn how to learn how to work on our feelings and acknowledge them."},{"id":"93","name":"If-else","type":"html","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Iss topic mai hum If-else ke bare mai janege"},{"id":"98","name":"Seva","type":"html","logo":"https://bit.ly/2TlR0WN","short_description":"NavGurukul ke 'Seva' model ke baare me jaanenge."},{"id":"121","name":"Operators","type":"html","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Iss topic mai hum Operators ke bare mai janege"},{"id":"102","name":"Variables","type":"html","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Iss topic mai hum Variables ke bare mai janege"},{"id":"18","name":"Basics of Programming using Python","type":"html","logo":"https://bit.ly/1h4FwSY","short_description":"We will learn the basics of programming using this course."},{"id":"100","name":"More Exercise Questions","type":"html","logo":"https://bit.ly/1h4FwSY","short_description":"We will solve more questions related to Python."},{"id":"99","name":"Files","type":"html","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Iss topic mai hum Files ke bare mai janege"},{"id":"105","name":"JSON (Using Python)","type":"html","logo":"https://cdn1.iconfinder.com/data/icons/it-terms/512/loop-512.png","short_description":"JSON ko thoda depth mein samajhte hain."},{"id":"122","name":"Data Types","type":"html","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Iss topic mai hum Data Type ke bare mai janege"},{"id":"106","name":"Interview Questions","type":"html","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Iss course mai hum apne alumni se jo questions puche gaye hai unne par work karenge"},{"id":"123","name":"Typing-Guru","type":"typing","logo":"http://navgurukul.org/img/sqlogo.jpg","short_description":"Let's learn typing"},{"id":"104","name":"Dictionary (Using Python)","type":"html","logo":"https://bit.ly/1h4FwSY","short_description":"Dictionary ko thoda depth mein samajhte hain."}],"completedCourses":[]}
--------------------------------------------------------------------------------
/node_modules/axios/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014-present Matt Zabriskie
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/node_modules/axios/README.md:
--------------------------------------------------------------------------------
1 | # axios
2 |
3 | [](https://www.npmjs.org/package/axios)
4 | [](https://cdnjs.com/libraries/axios)
5 | [](https://travis-ci.org/axios/axios)
6 | [](https://coveralls.io/r/mzabriskie/axios)
7 | [](https://packagephobia.now.sh/result?p=axios)
8 | [](http://npm-stat.com/charts.html?package=axios)
9 | [](https://gitter.im/mzabriskie/axios)
10 | [](https://www.codetriage.com/axios/axios)
11 |
12 | Promise based HTTP client for the browser and node.js
13 | ## Table of Contents
14 |
15 | - [Features](#features)
16 | - [Browser Support](#browser-support)
17 | - [Installing](#installing)
18 | - [Example](#example)
19 | - [Axios API](#axios-api)
20 | - [Request method aliases](#request-method-aliases)
21 | - [Concurrency (Deprecated)](#concurrency-deprecated)
22 | - [Creating an instance](#creating-an-instance)
23 | - [Instance methods](#instance-methods)
24 | - [Request Config](#request-config)
25 | - [Response Schema](#response-schema)
26 | - [Config Defaults](#config-defaults)
27 | - [Global axios defaults](#global-axios-defaults)
28 | - [Custom instance defaults](#custom-instance-defaults)
29 | - [Config order of precedence](#config-order-of-precedence)
30 | - [Interceptors](#interceptors)
31 | - [Handling Errors](#handling-errors)
32 | - [Cancellation](#cancellation)
33 | - [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
34 | - [Browser](#browser)
35 | - [Node.js](#nodejs)
36 | - [Query string](#query-string)
37 | - [Form data](#form-data)
38 | - [Semver](#semver)
39 | - [Promises](#promises)
40 | - [TypeScript](#typescript)
41 | - [Resources](#resources)
42 | - [Credits](#credits)
43 | - [License](#license)
44 |
45 | ## Features
46 |
47 | - Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser
48 | - Make [http](http://nodejs.org/api/http.html) requests from node.js
49 | - Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API
50 | - Intercept request and response
51 | - Transform request and response data
52 | - Cancel requests
53 | - Automatic transforms for JSON data
54 | - Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)
55 |
56 | ## Browser Support
57 |
58 |  |  |  |  |  |  |
59 | --- | --- | --- | --- | --- | --- |
60 | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
61 |
62 | [](https://saucelabs.com/u/axios)
63 |
64 | ## Installing
65 |
66 | Using npm:
67 |
68 | ```bash
69 | $ npm install axios
70 | ```
71 |
72 | Using bower:
73 |
74 | ```bash
75 | $ bower install axios
76 | ```
77 |
78 | Using yarn:
79 |
80 | ```bash
81 | $ yarn add axios
82 | ```
83 |
84 | Using jsDelivr CDN:
85 |
86 | ```html
87 |
88 | ```
89 |
90 | Using unpkg CDN:
91 |
92 | ```html
93 |
94 | ```
95 |
96 | ## Example
97 |
98 | ### note: CommonJS usage
99 | In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach:
100 |
101 | ```js
102 | const axios = require('axios').default;
103 |
104 | // axios. will now provide autocomplete and parameter typings
105 | ```
106 |
107 | Performing a `GET` request
108 |
109 | ```js
110 | const axios = require('axios');
111 |
112 | // Make a request for a user with a given ID
113 | axios.get('/user?ID=12345')
114 | .then(function (response) {
115 | // handle success
116 | console.log(response);
117 | })
118 | .catch(function (error) {
119 | // handle error
120 | console.log(error);
121 | })
122 | .then(function () {
123 | // always executed
124 | });
125 |
126 | // Optionally the request above could also be done as
127 | axios.get('/user', {
128 | params: {
129 | ID: 12345
130 | }
131 | })
132 | .then(function (response) {
133 | console.log(response);
134 | })
135 | .catch(function (error) {
136 | console.log(error);
137 | })
138 | .then(function () {
139 | // always executed
140 | });
141 |
142 | // Want to use async/await? Add the `async` keyword to your outer function/method.
143 | async function getUser() {
144 | try {
145 | const response = await axios.get('/user?ID=12345');
146 | console.log(response);
147 | } catch (error) {
148 | console.error(error);
149 | }
150 | }
151 | ```
152 |
153 | > **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet
154 | > Explorer and older browsers, so use with caution.
155 |
156 | Performing a `POST` request
157 |
158 | ```js
159 | axios.post('/user', {
160 | firstName: 'Fred',
161 | lastName: 'Flintstone'
162 | })
163 | .then(function (response) {
164 | console.log(response);
165 | })
166 | .catch(function (error) {
167 | console.log(error);
168 | });
169 | ```
170 |
171 | Performing multiple concurrent requests
172 |
173 | ```js
174 | function getUserAccount() {
175 | return axios.get('/user/12345');
176 | }
177 |
178 | function getUserPermissions() {
179 | return axios.get('/user/12345/permissions');
180 | }
181 |
182 | Promise.all([getUserAccount(), getUserPermissions()])
183 | .then(function (results) {
184 | const acct = results[0];
185 | const perm = results[1];
186 | });
187 | ```
188 |
189 | ## axios API
190 |
191 | Requests can be made by passing the relevant config to `axios`.
192 |
193 | ##### axios(config)
194 |
195 | ```js
196 | // Send a POST request
197 | axios({
198 | method: 'post',
199 | url: '/user/12345',
200 | data: {
201 | firstName: 'Fred',
202 | lastName: 'Flintstone'
203 | }
204 | });
205 | ```
206 |
207 | ```js
208 | // GET request for remote image in node.js
209 | axios({
210 | method: 'get',
211 | url: 'http://bit.ly/2mTM3nY',
212 | responseType: 'stream'
213 | })
214 | .then(function (response) {
215 | response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
216 | });
217 | ```
218 |
219 | ##### axios(url[, config])
220 |
221 | ```js
222 | // Send a GET request (default method)
223 | axios('/user/12345');
224 | ```
225 |
226 | ### Request method aliases
227 |
228 | For convenience aliases have been provided for all supported request methods.
229 |
230 | ##### axios.request(config)
231 | ##### axios.get(url[, config])
232 | ##### axios.delete(url[, config])
233 | ##### axios.head(url[, config])
234 | ##### axios.options(url[, config])
235 | ##### axios.post(url[, data[, config]])
236 | ##### axios.put(url[, data[, config]])
237 | ##### axios.patch(url[, data[, config]])
238 |
239 | ###### NOTE
240 | When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config.
241 |
242 | ### Concurrency (Deprecated)
243 | Please use `Promise.all` to replace the below functions.
244 |
245 | Helper functions for dealing with concurrent requests.
246 |
247 | axios.all(iterable)
248 | axios.spread(callback)
249 |
250 | ### Creating an instance
251 |
252 | You can create a new instance of axios with a custom config.
253 |
254 | ##### axios.create([config])
255 |
256 | ```js
257 | const instance = axios.create({
258 | baseURL: 'https://some-domain.com/api/',
259 | timeout: 1000,
260 | headers: {'X-Custom-Header': 'foobar'}
261 | });
262 | ```
263 |
264 | ### Instance methods
265 |
266 | The available instance methods are listed below. The specified config will be merged with the instance config.
267 |
268 | ##### axios#request(config)
269 | ##### axios#get(url[, config])
270 | ##### axios#delete(url[, config])
271 | ##### axios#head(url[, config])
272 | ##### axios#options(url[, config])
273 | ##### axios#post(url[, data[, config]])
274 | ##### axios#put(url[, data[, config]])
275 | ##### axios#patch(url[, data[, config]])
276 | ##### axios#getUri([config])
277 |
278 | ## Request Config
279 |
280 | These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified.
281 |
282 | ```js
283 | {
284 | // `url` is the server URL that will be used for the request
285 | url: '/user',
286 |
287 | // `method` is the request method to be used when making the request
288 | method: 'get', // default
289 |
290 | // `baseURL` will be prepended to `url` unless `url` is absolute.
291 | // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
292 | // to methods of that instance.
293 | baseURL: 'https://some-domain.com/api/',
294 |
295 | // `transformRequest` allows changes to the request data before it is sent to the server
296 | // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE'
297 | // The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
298 | // FormData or Stream
299 | // You may modify the headers object.
300 | transformRequest: [function (data, headers) {
301 | // Do whatever you want to transform the data
302 |
303 | return data;
304 | }],
305 |
306 | // `transformResponse` allows changes to the response data to be made before
307 | // it is passed to then/catch
308 | transformResponse: [function (data) {
309 | // Do whatever you want to transform the data
310 |
311 | return data;
312 | }],
313 |
314 | // `headers` are custom headers to be sent
315 | headers: {'X-Requested-With': 'XMLHttpRequest'},
316 |
317 | // `params` are the URL parameters to be sent with the request
318 | // Must be a plain object or a URLSearchParams object
319 | params: {
320 | ID: 12345
321 | },
322 |
323 | // `paramsSerializer` is an optional function in charge of serializing `params`
324 | // (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
325 | paramsSerializer: function (params) {
326 | return Qs.stringify(params, {arrayFormat: 'brackets'})
327 | },
328 |
329 | // `data` is the data to be sent as the request body
330 | // Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'
331 | // When no `transformRequest` is set, must be of one of the following types:
332 | // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
333 | // - Browser only: FormData, File, Blob
334 | // - Node only: Stream, Buffer
335 | data: {
336 | firstName: 'Fred'
337 | },
338 |
339 | // syntax alternative to send data into the body
340 | // method post
341 | // only the value is sent, not the key
342 | data: 'Country=Brasil&City=Belo Horizonte',
343 |
344 | // `timeout` specifies the number of milliseconds before the request times out.
345 | // If the request takes longer than `timeout`, the request will be aborted.
346 | timeout: 1000, // default is `0` (no timeout)
347 |
348 | // `withCredentials` indicates whether or not cross-site Access-Control requests
349 | // should be made using credentials
350 | withCredentials: false, // default
351 |
352 | // `adapter` allows custom handling of requests which makes testing easier.
353 | // Return a promise and supply a valid response (see lib/adapters/README.md).
354 | adapter: function (config) {
355 | /* ... */
356 | },
357 |
358 | // `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
359 | // This will set an `Authorization` header, overwriting any existing
360 | // `Authorization` custom headers you have set using `headers`.
361 | // Please note that only HTTP Basic auth is configurable through this parameter.
362 | // For Bearer tokens and such, use `Authorization` custom headers instead.
363 | auth: {
364 | username: 'janedoe',
365 | password: 's00pers3cret'
366 | },
367 |
368 | // `responseType` indicates the type of data that the server will respond with
369 | // options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
370 | // browser only: 'blob'
371 | responseType: 'json', // default
372 |
373 | // `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
374 | // Note: Ignored for `responseType` of 'stream' or client-side requests
375 | responseEncoding: 'utf8', // default
376 |
377 | // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
378 | xsrfCookieName: 'XSRF-TOKEN', // default
379 |
380 | // `xsrfHeaderName` is the name of the http header that carries the xsrf token value
381 | xsrfHeaderName: 'X-XSRF-TOKEN', // default
382 |
383 | // `onUploadProgress` allows handling of progress events for uploads
384 | // browser only
385 | onUploadProgress: function (progressEvent) {
386 | // Do whatever you want with the native progress event
387 | },
388 |
389 | // `onDownloadProgress` allows handling of progress events for downloads
390 | // browser only
391 | onDownloadProgress: function (progressEvent) {
392 | // Do whatever you want with the native progress event
393 | },
394 |
395 | // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js
396 | maxContentLength: 2000,
397 |
398 | // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
399 | maxBodyLength: 2000,
400 |
401 | // `validateStatus` defines whether to resolve or reject the promise for a given
402 | // HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
403 | // or `undefined`), the promise will be resolved; otherwise, the promise will be
404 | // rejected.
405 | validateStatus: function (status) {
406 | return status >= 200 && status < 300; // default
407 | },
408 |
409 | // `maxRedirects` defines the maximum number of redirects to follow in node.js.
410 | // If set to 0, no redirects will be followed.
411 | maxRedirects: 5, // default
412 |
413 | // `socketPath` defines a UNIX Socket to be used in node.js.
414 | // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
415 | // Only either `socketPath` or `proxy` can be specified.
416 | // If both are specified, `socketPath` is used.
417 | socketPath: null, // default
418 |
419 | // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
420 | // and https requests, respectively, in node.js. This allows options to be added like
421 | // `keepAlive` that are not enabled by default.
422 | httpAgent: new http.Agent({ keepAlive: true }),
423 | httpsAgent: new https.Agent({ keepAlive: true }),
424 |
425 | // `proxy` defines the hostname, port, and protocol of the proxy server.
426 | // You can also define your proxy using the conventional `http_proxy` and
427 | // `https_proxy` environment variables. If you are using environment variables
428 | // for your proxy configuration, you can also define a `no_proxy` environment
429 | // variable as a comma-separated list of domains that should not be proxied.
430 | // Use `false` to disable proxies, ignoring environment variables.
431 | // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
432 | // supplies credentials.
433 | // This will set an `Proxy-Authorization` header, overwriting any existing
434 | // `Proxy-Authorization` custom headers you have set using `headers`.
435 | // If the proxy server uses HTTPS, then you must set the protocol to `https`.
436 | proxy: {
437 | protocol: 'https',
438 | host: '127.0.0.1',
439 | port: 9000,
440 | auth: {
441 | username: 'mikeymike',
442 | password: 'rapunz3l'
443 | }
444 | },
445 |
446 | // `cancelToken` specifies a cancel token that can be used to cancel the request
447 | // (see Cancellation section below for details)
448 | cancelToken: new CancelToken(function (cancel) {
449 | }),
450 |
451 | // `decompress` indicates whether or not the response body should be decompressed
452 | // automatically. If set to `true` will also remove the 'content-encoding' header
453 | // from the responses objects of all decompressed responses
454 | // - Node only (XHR cannot turn off decompression)
455 | decompress: true // default
456 |
457 | }
458 | ```
459 |
460 | ## Response Schema
461 |
462 | The response for a request contains the following information.
463 |
464 | ```js
465 | {
466 | // `data` is the response that was provided by the server
467 | data: {},
468 |
469 | // `status` is the HTTP status code from the server response
470 | status: 200,
471 |
472 | // `statusText` is the HTTP status message from the server response
473 | statusText: 'OK',
474 |
475 | // `headers` the HTTP headers that the server responded with
476 | // All header names are lower cased and can be accessed using the bracket notation.
477 | // Example: `response.headers['content-type']`
478 | headers: {},
479 |
480 | // `config` is the config that was provided to `axios` for the request
481 | config: {},
482 |
483 | // `request` is the request that generated this response
484 | // It is the last ClientRequest instance in node.js (in redirects)
485 | // and an XMLHttpRequest instance in the browser
486 | request: {}
487 | }
488 | ```
489 |
490 | When using `then`, you will receive the response as follows:
491 |
492 | ```js
493 | axios.get('/user/12345')
494 | .then(function (response) {
495 | console.log(response.data);
496 | console.log(response.status);
497 | console.log(response.statusText);
498 | console.log(response.headers);
499 | console.log(response.config);
500 | });
501 | ```
502 |
503 | When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](#handling-errors) section.
504 |
505 | ## Config Defaults
506 |
507 | You can specify config defaults that will be applied to every request.
508 |
509 | ### Global axios defaults
510 |
511 | ```js
512 | axios.defaults.baseURL = 'https://api.example.com';
513 | axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
514 | axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
515 | ```
516 |
517 | ### Custom instance defaults
518 |
519 | ```js
520 | // Set config defaults when creating the instance
521 | const instance = axios.create({
522 | baseURL: 'https://api.example.com'
523 | });
524 |
525 | // Alter defaults after instance has been created
526 | instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
527 | ```
528 |
529 | ### Config order of precedence
530 |
531 | Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
532 |
533 | ```js
534 | // Create an instance using the config defaults provided by the library
535 | // At this point the timeout config value is `0` as is the default for the library
536 | const instance = axios.create();
537 |
538 | // Override timeout default for the library
539 | // Now all requests using this instance will wait 2.5 seconds before timing out
540 | instance.defaults.timeout = 2500;
541 |
542 | // Override timeout for this request as it's known to take a long time
543 | instance.get('/longRequest', {
544 | timeout: 5000
545 | });
546 | ```
547 |
548 | ## Interceptors
549 |
550 | You can intercept requests or responses before they are handled by `then` or `catch`.
551 |
552 | ```js
553 | // Add a request interceptor
554 | axios.interceptors.request.use(function (config) {
555 | // Do something before request is sent
556 | return config;
557 | }, function (error) {
558 | // Do something with request error
559 | return Promise.reject(error);
560 | });
561 |
562 | // Add a response interceptor
563 | axios.interceptors.response.use(function (response) {
564 | // Any status code that lie within the range of 2xx cause this function to trigger
565 | // Do something with response data
566 | return response;
567 | }, function (error) {
568 | // Any status codes that falls outside the range of 2xx cause this function to trigger
569 | // Do something with response error
570 | return Promise.reject(error);
571 | });
572 | ```
573 |
574 | If you need to remove an interceptor later you can.
575 |
576 | ```js
577 | const myInterceptor = axios.interceptors.request.use(function () {/*...*/});
578 | axios.interceptors.request.eject(myInterceptor);
579 | ```
580 |
581 | You can add interceptors to a custom instance of axios.
582 |
583 | ```js
584 | const instance = axios.create();
585 | instance.interceptors.request.use(function () {/*...*/});
586 | ```
587 |
588 | ## Handling Errors
589 |
590 | ```js
591 | axios.get('/user/12345')
592 | .catch(function (error) {
593 | if (error.response) {
594 | // The request was made and the server responded with a status code
595 | // that falls out of the range of 2xx
596 | console.log(error.response.data);
597 | console.log(error.response.status);
598 | console.log(error.response.headers);
599 | } else if (error.request) {
600 | // The request was made but no response was received
601 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
602 | // http.ClientRequest in node.js
603 | console.log(error.request);
604 | } else {
605 | // Something happened in setting up the request that triggered an Error
606 | console.log('Error', error.message);
607 | }
608 | console.log(error.config);
609 | });
610 | ```
611 |
612 | Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error.
613 |
614 | ```js
615 | axios.get('/user/12345', {
616 | validateStatus: function (status) {
617 | return status < 500; // Resolve only if the status code is less than 500
618 | }
619 | })
620 | ```
621 |
622 | Using `toJSON` you get an object with more information about the HTTP error.
623 |
624 | ```js
625 | axios.get('/user/12345')
626 | .catch(function (error) {
627 | console.log(error.toJSON());
628 | });
629 | ```
630 |
631 | ## Cancellation
632 |
633 | You can cancel a request using a *cancel token*.
634 |
635 | > The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
636 |
637 | You can create a cancel token using the `CancelToken.source` factory as shown below:
638 |
639 | ```js
640 | const CancelToken = axios.CancelToken;
641 | const source = CancelToken.source();
642 |
643 | axios.get('/user/12345', {
644 | cancelToken: source.token
645 | }).catch(function (thrown) {
646 | if (axios.isCancel(thrown)) {
647 | console.log('Request canceled', thrown.message);
648 | } else {
649 | // handle error
650 | }
651 | });
652 |
653 | axios.post('/user/12345', {
654 | name: 'new name'
655 | }, {
656 | cancelToken: source.token
657 | })
658 |
659 | // cancel the request (the message parameter is optional)
660 | source.cancel('Operation canceled by the user.');
661 | ```
662 |
663 | You can also create a cancel token by passing an executor function to the `CancelToken` constructor:
664 |
665 | ```js
666 | const CancelToken = axios.CancelToken;
667 | let cancel;
668 |
669 | axios.get('/user/12345', {
670 | cancelToken: new CancelToken(function executor(c) {
671 | // An executor function receives a cancel function as a parameter
672 | cancel = c;
673 | })
674 | });
675 |
676 | // cancel the request
677 | cancel();
678 | ```
679 |
680 | > Note: you can cancel several requests with the same cancel token.
681 |
682 | ## Using application/x-www-form-urlencoded format
683 |
684 | By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following options.
685 |
686 | ### Browser
687 |
688 | In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows:
689 |
690 | ```js
691 | const params = new URLSearchParams();
692 | params.append('param1', 'value1');
693 | params.append('param2', 'value2');
694 | axios.post('/foo', params);
695 | ```
696 |
697 | > Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment).
698 |
699 | Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library:
700 |
701 | ```js
702 | const qs = require('qs');
703 | axios.post('/foo', qs.stringify({ 'bar': 123 }));
704 | ```
705 |
706 | Or in another way (ES6),
707 |
708 | ```js
709 | import qs from 'qs';
710 | const data = { 'bar': 123 };
711 | const options = {
712 | method: 'POST',
713 | headers: { 'content-type': 'application/x-www-form-urlencoded' },
714 | data: qs.stringify(data),
715 | url,
716 | };
717 | axios(options);
718 | ```
719 |
720 | ### Node.js
721 |
722 | #### Query string
723 |
724 | In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
725 |
726 | ```js
727 | const querystring = require('querystring');
728 | axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
729 | ```
730 |
731 | or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows:
732 |
733 | ```js
734 | const url = require('url');
735 | const params = new url.URLSearchParams({ foo: 'bar' });
736 | axios.post('http://something.com/', params.toString());
737 | ```
738 |
739 | You can also use the [`qs`](https://github.com/ljharb/qs) library.
740 |
741 | ###### NOTE
742 | The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665).
743 |
744 | #### Form data
745 |
746 | In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows:
747 |
748 | ```js
749 | const FormData = require('form-data');
750 |
751 | const form = new FormData();
752 | form.append('my_field', 'my value');
753 | form.append('my_buffer', new Buffer(10));
754 | form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
755 |
756 | axios.post('https://example.com', form, { headers: form.getHeaders() })
757 | ```
758 |
759 | Alternatively, use an interceptor:
760 |
761 | ```js
762 | axios.interceptors.request.use(config => {
763 | if (config.data instanceof FormData) {
764 | Object.assign(config.headers, config.data.getHeaders());
765 | }
766 | return config;
767 | });
768 | ```
769 |
770 | ## Semver
771 |
772 | Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes.
773 |
774 | ## Promises
775 |
776 | axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises).
777 | If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
778 |
779 | ## TypeScript
780 | axios includes [TypeScript](http://typescriptlang.org) definitions.
781 | ```typescript
782 | import axios from 'axios';
783 | axios.get('/user?ID=12345');
784 | ```
785 |
786 | ## Resources
787 |
788 | * [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
789 | * [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md)
790 | * [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md)
791 | * [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md)
792 | * [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md)
793 |
794 | ## Credits
795 |
796 | axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular.
797 |
798 | ## License
799 |
800 | [MIT](LICENSE)
801 |
--------------------------------------------------------------------------------
/node_modules/axios/UPGRADE_GUIDE.md:
--------------------------------------------------------------------------------
1 | # Upgrade Guide
2 |
3 | ### 0.15.x -> 0.16.0
4 |
5 | #### `Promise` Type Declarations
6 |
7 | The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details.
8 |
9 | ### 0.13.x -> 0.14.0
10 |
11 | #### TypeScript Definitions
12 |
13 | The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax.
14 |
15 | Please use the following `import` statement to import axios in TypeScript:
16 |
17 | ```typescript
18 | import axios from 'axios';
19 |
20 | axios.get('/foo')
21 | .then(response => console.log(response))
22 | .catch(error => console.log(error));
23 | ```
24 |
25 | #### `agent` Config Option
26 |
27 | The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead.
28 |
29 | ```js
30 | {
31 | // Define a custom agent for HTTP
32 | httpAgent: new http.Agent({ keepAlive: true }),
33 | // Define a custom agent for HTTPS
34 | httpsAgent: new https.Agent({ keepAlive: true })
35 | }
36 | ```
37 |
38 | #### `progress` Config Option
39 |
40 | The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options.
41 |
42 | ```js
43 | {
44 | // Define a handler for upload progress events
45 | onUploadProgress: function (progressEvent) {
46 | // ...
47 | },
48 |
49 | // Define a handler for download progress events
50 | onDownloadProgress: function (progressEvent) {
51 | // ...
52 | }
53 | }
54 | ```
55 |
56 | ### 0.12.x -> 0.13.0
57 |
58 | The `0.13.0` release contains several changes to custom adapters and error handling.
59 |
60 | #### Error Handling
61 |
62 | Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response.
63 |
64 | ```js
65 | axios.get('/user/12345')
66 | .catch((error) => {
67 | console.log(error.message);
68 | console.log(error.code); // Not always specified
69 | console.log(error.config); // The config that was used to make the request
70 | console.log(error.response); // Only available if response was received from the server
71 | });
72 | ```
73 |
74 | #### Request Adapters
75 |
76 | This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter.
77 |
78 | 1. Response transformer is now called outside of adapter.
79 | 2. Request adapter returns a `Promise`.
80 |
81 | This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter.
82 |
83 | Previous code:
84 |
85 | ```js
86 | function myAdapter(resolve, reject, config) {
87 | var response = {
88 | data: transformData(
89 | responseData,
90 | responseHeaders,
91 | config.transformResponse
92 | ),
93 | status: request.status,
94 | statusText: request.statusText,
95 | headers: responseHeaders
96 | };
97 | settle(resolve, reject, response);
98 | }
99 | ```
100 |
101 | New code:
102 |
103 | ```js
104 | function myAdapter(config) {
105 | return new Promise(function (resolve, reject) {
106 | var response = {
107 | data: responseData,
108 | status: request.status,
109 | statusText: request.statusText,
110 | headers: responseHeaders
111 | };
112 | settle(resolve, reject, response);
113 | });
114 | }
115 | ```
116 |
117 | See the related commits for more details:
118 | - [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
119 | - [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
120 |
121 | ### 0.5.x -> 0.6.0
122 |
123 | The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading.
124 |
125 | #### ES6 Promise Polyfill
126 |
127 | Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it.
128 |
129 | ```js
130 | require('es6-promise').polyfill();
131 | var axios = require('axios');
132 | ```
133 |
134 | This will polyfill the global environment, and only needs to be done once.
135 |
136 | #### `axios.success`/`axios.error`
137 |
138 | The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively.
139 |
140 | ```js
141 | axios.get('some/url')
142 | .then(function (res) {
143 | /* ... */
144 | })
145 | .catch(function (err) {
146 | /* ... */
147 | });
148 | ```
149 |
150 | #### UMD
151 |
152 | Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build.
153 |
154 | ```js
155 | // AMD
156 | require(['bower_components/axios/dist/axios'], function (axios) {
157 | /* ... */
158 | });
159 |
160 | // CommonJS
161 | var axios = require('axios/dist/axios');
162 | ```
163 |
--------------------------------------------------------------------------------
/node_modules/axios/dist/axios.min.js:
--------------------------------------------------------------------------------
1 | /* axios v0.21.1 | (c) 2020 by Matt Zabriskie */
2 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(4),a=n(22),u=n(10),c=r(u);c.Axios=i,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(9),c.all=function(e){return Promise.all(e)},c.spread=n(25),c.isAxiosError=n(26),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===R.call(e)}function o(e){return"undefined"==typeof e}function s(e){return null!==e&&!o(e)&&null!==e.constructor&&!o(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function i(e){return"[object ArrayBuffer]"===R.call(e)}function a(e){return"undefined"!=typeof FormData&&e instanceof FormData}function u(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function c(e){return"string"==typeof e}function f(e){return"number"==typeof e}function p(e){return null!==e&&"object"==typeof e}function d(e){if("[object Object]"!==R.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function l(e){return"[object Date]"===R.call(e)}function h(e){return"[object File]"===R.call(e)}function m(e){return"[object Blob]"===R.call(e)}function y(e){return"[object Function]"===R.call(e)}function g(e){return p(e)&&y(e.pipe)}function v(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function x(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function w(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function b(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],function(e){u.headers[e]={}}),s.forEach(["post","put","patch"],function(e){u.headers[e]=s.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(13),s=n(16),i=n(5),a=n(17),u=n(20),c=n(21),f=n(14);e.exports=function(e){return new Promise(function(t,n){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(h+":"+m)}var y=a(e.baseURL,e.url);if(l.open(e.method.toUpperCase(),i(y,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l.onreadystatechange=function(){if(l&&4===l.readyState&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in l?u(l.getAllResponseHeaders()):null,s=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:s,status:l.status,statusText:l.statusText,headers:r,config:e,request:l};o(t,n,i),l=null}},l.onabort=function(){l&&(n(f("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){n(f("Network Error",e,null,l)),l=null},l.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var g=(e.withCredentials||c(y))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;g&&(d[e.xsrfHeaderName]=g)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),r.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),n(e),l=null)}),p||(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(14);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n,o,s){var i=new Error(e);return r(i,t,n,o,s)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";var r=n(18),o=n(19);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,s,i={};return e?(r.forEach(e.split("\n"),function(e){if(s=e.indexOf(":"),t=r.trim(e.substr(0,s)).toLowerCase(),n=r.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?i[t]=(i[t]?i[t]:[]).concat([n]):i[t]=i[t]?i[t]+", "+n:n}}),i):i}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){function n(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function o(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(s[o]=n(void 0,e[o])):s[o]=n(e[o],t[o])}t=t||{};var s={},i=["url","method","data"],a=["headers","auth","proxy","params"],u=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],c=["validateStatus"];r.forEach(i,function(e){r.isUndefined(t[e])||(s[e]=n(void 0,t[e]))}),r.forEach(a,o),r.forEach(u,function(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(s[o]=n(void 0,e[o])):s[o]=n(void 0,t[o])}),r.forEach(c,function(r){r in t?s[r]=n(e[r],t[r]):r in e&&(s[r]=n(void 0,e[r]))});var f=i.concat(a).concat(u).concat(c),p=Object.keys(e).concat(Object.keys(t)).filter(function(e){return f.indexOf(e)===-1});return r.forEach(p,o),s}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t){"use strict";e.exports=function(e){return"object"==typeof e&&e.isAxiosError===!0}}])});
3 | //# sourceMappingURL=axios.min.map
--------------------------------------------------------------------------------
/node_modules/axios/index.d.ts:
--------------------------------------------------------------------------------
1 | export interface AxiosTransformer {
2 | (data: any, headers?: any): any;
3 | }
4 |
5 | export interface AxiosAdapter {
6 | (config: AxiosRequestConfig): AxiosPromise;
7 | }
8 |
9 | export interface AxiosBasicCredentials {
10 | username: string;
11 | password: string;
12 | }
13 |
14 | export interface AxiosProxyConfig {
15 | host: string;
16 | port: number;
17 | auth?: {
18 | username: string;
19 | password:string;
20 | };
21 | protocol?: string;
22 | }
23 |
24 | export type Method =
25 | | 'get' | 'GET'
26 | | 'delete' | 'DELETE'
27 | | 'head' | 'HEAD'
28 | | 'options' | 'OPTIONS'
29 | | 'post' | 'POST'
30 | | 'put' | 'PUT'
31 | | 'patch' | 'PATCH'
32 | | 'purge' | 'PURGE'
33 | | 'link' | 'LINK'
34 | | 'unlink' | 'UNLINK'
35 |
36 | export type ResponseType =
37 | | 'arraybuffer'
38 | | 'blob'
39 | | 'document'
40 | | 'json'
41 | | 'text'
42 | | 'stream'
43 |
44 | export interface AxiosRequestConfig {
45 | url?: string;
46 | method?: Method;
47 | baseURL?: string;
48 | transformRequest?: AxiosTransformer | AxiosTransformer[];
49 | transformResponse?: AxiosTransformer | AxiosTransformer[];
50 | headers?: any;
51 | params?: any;
52 | paramsSerializer?: (params: any) => string;
53 | data?: any;
54 | timeout?: number;
55 | timeoutErrorMessage?: string;
56 | withCredentials?: boolean;
57 | adapter?: AxiosAdapter;
58 | auth?: AxiosBasicCredentials;
59 | responseType?: ResponseType;
60 | xsrfCookieName?: string;
61 | xsrfHeaderName?: string;
62 | onUploadProgress?: (progressEvent: any) => void;
63 | onDownloadProgress?: (progressEvent: any) => void;
64 | maxContentLength?: number;
65 | validateStatus?: ((status: number) => boolean) | null;
66 | maxBodyLength?: number;
67 | maxRedirects?: number;
68 | socketPath?: string | null;
69 | httpAgent?: any;
70 | httpsAgent?: any;
71 | proxy?: AxiosProxyConfig | false;
72 | cancelToken?: CancelToken;
73 | decompress?: boolean;
74 | }
75 |
76 | export interface AxiosResponse {
77 | data: T;
78 | status: number;
79 | statusText: string;
80 | headers: any;
81 | config: AxiosRequestConfig;
82 | request?: any;
83 | }
84 |
85 | export interface AxiosError extends Error {
86 | config: AxiosRequestConfig;
87 | code?: string;
88 | request?: any;
89 | response?: AxiosResponse;
90 | isAxiosError: boolean;
91 | toJSON: () => object;
92 | }
93 |
94 | export interface AxiosPromise extends Promise> {
95 | }
96 |
97 | export interface CancelStatic {
98 | new (message?: string): Cancel;
99 | }
100 |
101 | export interface Cancel {
102 | message: string;
103 | }
104 |
105 | export interface Canceler {
106 | (message?: string): void;
107 | }
108 |
109 | export interface CancelTokenStatic {
110 | new (executor: (cancel: Canceler) => void): CancelToken;
111 | source(): CancelTokenSource;
112 | }
113 |
114 | export interface CancelToken {
115 | promise: Promise;
116 | reason?: Cancel;
117 | throwIfRequested(): void;
118 | }
119 |
120 | export interface CancelTokenSource {
121 | token: CancelToken;
122 | cancel: Canceler;
123 | }
124 |
125 | export interface AxiosInterceptorManager {
126 | use(onFulfilled?: (value: V) => V | Promise, onRejected?: (error: any) => any): number;
127 | eject(id: number): void;
128 | }
129 |
130 | export interface AxiosInstance {
131 | (config: AxiosRequestConfig): AxiosPromise;
132 | (url: string, config?: AxiosRequestConfig): AxiosPromise;
133 | defaults: AxiosRequestConfig;
134 | interceptors: {
135 | request: AxiosInterceptorManager;
136 | response: AxiosInterceptorManager;
137 | };
138 | getUri(config?: AxiosRequestConfig): string;
139 | request> (config: AxiosRequestConfig): Promise;
140 | get>(url: string, config?: AxiosRequestConfig): Promise;
141 | delete>(url: string, config?: AxiosRequestConfig): Promise;
142 | head>(url: string, config?: AxiosRequestConfig): Promise;
143 | options>(url: string, config?: AxiosRequestConfig): Promise;
144 | post>(url: string, data?: any, config?: AxiosRequestConfig): Promise;
145 | put>(url: string, data?: any, config?: AxiosRequestConfig): Promise;
146 | patch>(url: string, data?: any, config?: AxiosRequestConfig): Promise;
147 | }
148 |
149 | export interface AxiosStatic extends AxiosInstance {
150 | create(config?: AxiosRequestConfig): AxiosInstance;
151 | Cancel: CancelStatic;
152 | CancelToken: CancelTokenStatic;
153 | isCancel(value: any): boolean;
154 | all(values: (T | Promise)[]): Promise;
155 | spread(callback: (...args: T[]) => R): (array: T[]) => R;
156 | isAxiosError(payload: any): payload is AxiosError;
157 | }
158 |
159 | declare const axios: AxiosStatic;
160 |
161 | export default axios;
162 |
--------------------------------------------------------------------------------
/node_modules/axios/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./lib/axios');
--------------------------------------------------------------------------------
/node_modules/axios/lib/adapters/README.md:
--------------------------------------------------------------------------------
1 | # axios // adapters
2 |
3 | The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received.
4 |
5 | ## Example
6 |
7 | ```js
8 | var settle = require('./../core/settle');
9 |
10 | module.exports = function myAdapter(config) {
11 | // At this point:
12 | // - config has been merged with defaults
13 | // - request transformers have already run
14 | // - request interceptors have already run
15 |
16 | // Make the request using config provided
17 | // Upon response settle the Promise
18 |
19 | return new Promise(function(resolve, reject) {
20 |
21 | var response = {
22 | data: responseData,
23 | status: request.status,
24 | statusText: request.statusText,
25 | headers: responseHeaders,
26 | config: config,
27 | request: request
28 | };
29 |
30 | settle(resolve, reject, response);
31 |
32 | // From here:
33 | // - response transformers will run
34 | // - response interceptors will run
35 | });
36 | }
37 | ```
38 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/adapters/http.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 | var settle = require('./../core/settle');
5 | var buildFullPath = require('../core/buildFullPath');
6 | var buildURL = require('./../helpers/buildURL');
7 | var http = require('http');
8 | var https = require('https');
9 | var httpFollow = require('follow-redirects').http;
10 | var httpsFollow = require('follow-redirects').https;
11 | var url = require('url');
12 | var zlib = require('zlib');
13 | var pkg = require('./../../package.json');
14 | var createError = require('../core/createError');
15 | var enhanceError = require('../core/enhanceError');
16 |
17 | var isHttps = /https:?/;
18 |
19 | /**
20 | *
21 | * @param {http.ClientRequestArgs} options
22 | * @param {AxiosProxyConfig} proxy
23 | * @param {string} location
24 | */
25 | function setProxy(options, proxy, location) {
26 | options.hostname = proxy.host;
27 | options.host = proxy.host;
28 | options.port = proxy.port;
29 | options.path = location;
30 |
31 | // Basic proxy authorization
32 | if (proxy.auth) {
33 | var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
34 | options.headers['Proxy-Authorization'] = 'Basic ' + base64;
35 | }
36 |
37 | // If a proxy is used, any redirects must also pass through the proxy
38 | options.beforeRedirect = function beforeRedirect(redirection) {
39 | redirection.headers.host = redirection.host;
40 | setProxy(redirection, proxy, redirection.href);
41 | };
42 | }
43 |
44 | /*eslint consistent-return:0*/
45 | module.exports = function httpAdapter(config) {
46 | return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
47 | var resolve = function resolve(value) {
48 | resolvePromise(value);
49 | };
50 | var reject = function reject(value) {
51 | rejectPromise(value);
52 | };
53 | var data = config.data;
54 | var headers = config.headers;
55 |
56 | // Set User-Agent (required by some servers)
57 | // Only set header if it hasn't been set in config
58 | // See https://github.com/axios/axios/issues/69
59 | if (!headers['User-Agent'] && !headers['user-agent']) {
60 | headers['User-Agent'] = 'axios/' + pkg.version;
61 | }
62 |
63 | if (data && !utils.isStream(data)) {
64 | if (Buffer.isBuffer(data)) {
65 | // Nothing to do...
66 | } else if (utils.isArrayBuffer(data)) {
67 | data = Buffer.from(new Uint8Array(data));
68 | } else if (utils.isString(data)) {
69 | data = Buffer.from(data, 'utf-8');
70 | } else {
71 | return reject(createError(
72 | 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
73 | config
74 | ));
75 | }
76 |
77 | // Add Content-Length header if data exists
78 | headers['Content-Length'] = data.length;
79 | }
80 |
81 | // HTTP basic authentication
82 | var auth = undefined;
83 | if (config.auth) {
84 | var username = config.auth.username || '';
85 | var password = config.auth.password || '';
86 | auth = username + ':' + password;
87 | }
88 |
89 | // Parse url
90 | var fullPath = buildFullPath(config.baseURL, config.url);
91 | var parsed = url.parse(fullPath);
92 | var protocol = parsed.protocol || 'http:';
93 |
94 | if (!auth && parsed.auth) {
95 | var urlAuth = parsed.auth.split(':');
96 | var urlUsername = urlAuth[0] || '';
97 | var urlPassword = urlAuth[1] || '';
98 | auth = urlUsername + ':' + urlPassword;
99 | }
100 |
101 | if (auth) {
102 | delete headers.Authorization;
103 | }
104 |
105 | var isHttpsRequest = isHttps.test(protocol);
106 | var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
107 |
108 | var options = {
109 | path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
110 | method: config.method.toUpperCase(),
111 | headers: headers,
112 | agent: agent,
113 | agents: { http: config.httpAgent, https: config.httpsAgent },
114 | auth: auth
115 | };
116 |
117 | if (config.socketPath) {
118 | options.socketPath = config.socketPath;
119 | } else {
120 | options.hostname = parsed.hostname;
121 | options.port = parsed.port;
122 | }
123 |
124 | var proxy = config.proxy;
125 | if (!proxy && proxy !== false) {
126 | var proxyEnv = protocol.slice(0, -1) + '_proxy';
127 | var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
128 | if (proxyUrl) {
129 | var parsedProxyUrl = url.parse(proxyUrl);
130 | var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
131 | var shouldProxy = true;
132 |
133 | if (noProxyEnv) {
134 | var noProxy = noProxyEnv.split(',').map(function trim(s) {
135 | return s.trim();
136 | });
137 |
138 | shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
139 | if (!proxyElement) {
140 | return false;
141 | }
142 | if (proxyElement === '*') {
143 | return true;
144 | }
145 | if (proxyElement[0] === '.' &&
146 | parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
147 | return true;
148 | }
149 |
150 | return parsed.hostname === proxyElement;
151 | });
152 | }
153 |
154 | if (shouldProxy) {
155 | proxy = {
156 | host: parsedProxyUrl.hostname,
157 | port: parsedProxyUrl.port,
158 | protocol: parsedProxyUrl.protocol
159 | };
160 |
161 | if (parsedProxyUrl.auth) {
162 | var proxyUrlAuth = parsedProxyUrl.auth.split(':');
163 | proxy.auth = {
164 | username: proxyUrlAuth[0],
165 | password: proxyUrlAuth[1]
166 | };
167 | }
168 | }
169 | }
170 | }
171 |
172 | if (proxy) {
173 | options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
174 | setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
175 | }
176 |
177 | var transport;
178 | var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
179 | if (config.transport) {
180 | transport = config.transport;
181 | } else if (config.maxRedirects === 0) {
182 | transport = isHttpsProxy ? https : http;
183 | } else {
184 | if (config.maxRedirects) {
185 | options.maxRedirects = config.maxRedirects;
186 | }
187 | transport = isHttpsProxy ? httpsFollow : httpFollow;
188 | }
189 |
190 | if (config.maxBodyLength > -1) {
191 | options.maxBodyLength = config.maxBodyLength;
192 | }
193 |
194 | // Create the request
195 | var req = transport.request(options, function handleResponse(res) {
196 | if (req.aborted) return;
197 |
198 | // uncompress the response body transparently if required
199 | var stream = res;
200 |
201 | // return the last request in case of redirects
202 | var lastRequest = res.req || req;
203 |
204 |
205 | // if no content, is HEAD request or decompress disabled we should not decompress
206 | if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
207 | switch (res.headers['content-encoding']) {
208 | /*eslint default-case:0*/
209 | case 'gzip':
210 | case 'compress':
211 | case 'deflate':
212 | // add the unzipper to the body stream processing pipeline
213 | stream = stream.pipe(zlib.createUnzip());
214 |
215 | // remove the content-encoding in order to not confuse downstream operations
216 | delete res.headers['content-encoding'];
217 | break;
218 | }
219 | }
220 |
221 | var response = {
222 | status: res.statusCode,
223 | statusText: res.statusMessage,
224 | headers: res.headers,
225 | config: config,
226 | request: lastRequest
227 | };
228 |
229 | if (config.responseType === 'stream') {
230 | response.data = stream;
231 | settle(resolve, reject, response);
232 | } else {
233 | var responseBuffer = [];
234 | stream.on('data', function handleStreamData(chunk) {
235 | responseBuffer.push(chunk);
236 |
237 | // make sure the content length is not over the maxContentLength if specified
238 | if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
239 | stream.destroy();
240 | reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
241 | config, null, lastRequest));
242 | }
243 | });
244 |
245 | stream.on('error', function handleStreamError(err) {
246 | if (req.aborted) return;
247 | reject(enhanceError(err, config, null, lastRequest));
248 | });
249 |
250 | stream.on('end', function handleStreamEnd() {
251 | var responseData = Buffer.concat(responseBuffer);
252 | if (config.responseType !== 'arraybuffer') {
253 | responseData = responseData.toString(config.responseEncoding);
254 | if (!config.responseEncoding || config.responseEncoding === 'utf8') {
255 | responseData = utils.stripBOM(responseData);
256 | }
257 | }
258 |
259 | response.data = responseData;
260 | settle(resolve, reject, response);
261 | });
262 | }
263 | });
264 |
265 | // Handle errors
266 | req.on('error', function handleRequestError(err) {
267 | if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
268 | reject(enhanceError(err, config, null, req));
269 | });
270 |
271 | // Handle request timeout
272 | if (config.timeout) {
273 | // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
274 | // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
275 | // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
276 | // And then these socket which be hang up will devoring CPU little by little.
277 | // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
278 | req.setTimeout(config.timeout, function handleRequestTimeout() {
279 | req.abort();
280 | reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
281 | });
282 | }
283 |
284 | if (config.cancelToken) {
285 | // Handle cancellation
286 | config.cancelToken.promise.then(function onCanceled(cancel) {
287 | if (req.aborted) return;
288 |
289 | req.abort();
290 | reject(cancel);
291 | });
292 | }
293 |
294 | // Send the request
295 | if (utils.isStream(data)) {
296 | data.on('error', function handleStreamError(err) {
297 | reject(enhanceError(err, config, null, req));
298 | }).pipe(req);
299 | } else {
300 | req.end(data);
301 | }
302 | });
303 | };
304 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/adapters/xhr.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 | var settle = require('./../core/settle');
5 | var cookies = require('./../helpers/cookies');
6 | var buildURL = require('./../helpers/buildURL');
7 | var buildFullPath = require('../core/buildFullPath');
8 | var parseHeaders = require('./../helpers/parseHeaders');
9 | var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
10 | var createError = require('../core/createError');
11 |
12 | module.exports = function xhrAdapter(config) {
13 | return new Promise(function dispatchXhrRequest(resolve, reject) {
14 | var requestData = config.data;
15 | var requestHeaders = config.headers;
16 |
17 | if (utils.isFormData(requestData)) {
18 | delete requestHeaders['Content-Type']; // Let the browser set it
19 | }
20 |
21 | var request = new XMLHttpRequest();
22 |
23 | // HTTP basic authentication
24 | if (config.auth) {
25 | var username = config.auth.username || '';
26 | var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
27 | requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
28 | }
29 |
30 | var fullPath = buildFullPath(config.baseURL, config.url);
31 | request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
32 |
33 | // Set the request timeout in MS
34 | request.timeout = config.timeout;
35 |
36 | // Listen for ready state
37 | request.onreadystatechange = function handleLoad() {
38 | if (!request || request.readyState !== 4) {
39 | return;
40 | }
41 |
42 | // The request errored out and we didn't get a response, this will be
43 | // handled by onerror instead
44 | // With one exception: request that using file: protocol, most browsers
45 | // will return status as 0 even though it's a successful request
46 | if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
47 | return;
48 | }
49 |
50 | // Prepare the response
51 | var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
52 | var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
53 | var response = {
54 | data: responseData,
55 | status: request.status,
56 | statusText: request.statusText,
57 | headers: responseHeaders,
58 | config: config,
59 | request: request
60 | };
61 |
62 | settle(resolve, reject, response);
63 |
64 | // Clean up request
65 | request = null;
66 | };
67 |
68 | // Handle browser request cancellation (as opposed to a manual cancellation)
69 | request.onabort = function handleAbort() {
70 | if (!request) {
71 | return;
72 | }
73 |
74 | reject(createError('Request aborted', config, 'ECONNABORTED', request));
75 |
76 | // Clean up request
77 | request = null;
78 | };
79 |
80 | // Handle low level network errors
81 | request.onerror = function handleError() {
82 | // Real errors are hidden from us by the browser
83 | // onerror should only fire if it's a network error
84 | reject(createError('Network Error', config, null, request));
85 |
86 | // Clean up request
87 | request = null;
88 | };
89 |
90 | // Handle timeout
91 | request.ontimeout = function handleTimeout() {
92 | var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
93 | if (config.timeoutErrorMessage) {
94 | timeoutErrorMessage = config.timeoutErrorMessage;
95 | }
96 | reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
97 | request));
98 |
99 | // Clean up request
100 | request = null;
101 | };
102 |
103 | // Add xsrf header
104 | // This is only done if running in a standard browser environment.
105 | // Specifically not if we're in a web worker, or react-native.
106 | if (utils.isStandardBrowserEnv()) {
107 | // Add xsrf header
108 | var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
109 | cookies.read(config.xsrfCookieName) :
110 | undefined;
111 |
112 | if (xsrfValue) {
113 | requestHeaders[config.xsrfHeaderName] = xsrfValue;
114 | }
115 | }
116 |
117 | // Add headers to the request
118 | if ('setRequestHeader' in request) {
119 | utils.forEach(requestHeaders, function setRequestHeader(val, key) {
120 | if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
121 | // Remove Content-Type if data is undefined
122 | delete requestHeaders[key];
123 | } else {
124 | // Otherwise add header to the request
125 | request.setRequestHeader(key, val);
126 | }
127 | });
128 | }
129 |
130 | // Add withCredentials to request if needed
131 | if (!utils.isUndefined(config.withCredentials)) {
132 | request.withCredentials = !!config.withCredentials;
133 | }
134 |
135 | // Add responseType to request if needed
136 | if (config.responseType) {
137 | try {
138 | request.responseType = config.responseType;
139 | } catch (e) {
140 | // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
141 | // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
142 | if (config.responseType !== 'json') {
143 | throw e;
144 | }
145 | }
146 | }
147 |
148 | // Handle progress if needed
149 | if (typeof config.onDownloadProgress === 'function') {
150 | request.addEventListener('progress', config.onDownloadProgress);
151 | }
152 |
153 | // Not all browsers support upload events
154 | if (typeof config.onUploadProgress === 'function' && request.upload) {
155 | request.upload.addEventListener('progress', config.onUploadProgress);
156 | }
157 |
158 | if (config.cancelToken) {
159 | // Handle cancellation
160 | config.cancelToken.promise.then(function onCanceled(cancel) {
161 | if (!request) {
162 | return;
163 | }
164 |
165 | request.abort();
166 | reject(cancel);
167 | // Clean up request
168 | request = null;
169 | });
170 | }
171 |
172 | if (!requestData) {
173 | requestData = null;
174 | }
175 |
176 | // Send the request
177 | request.send(requestData);
178 | });
179 | };
180 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/axios.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./utils');
4 | var bind = require('./helpers/bind');
5 | var Axios = require('./core/Axios');
6 | var mergeConfig = require('./core/mergeConfig');
7 | var defaults = require('./defaults');
8 |
9 | /**
10 | * Create an instance of Axios
11 | *
12 | * @param {Object} defaultConfig The default config for the instance
13 | * @return {Axios} A new instance of Axios
14 | */
15 | function createInstance(defaultConfig) {
16 | var context = new Axios(defaultConfig);
17 | var instance = bind(Axios.prototype.request, context);
18 |
19 | // Copy axios.prototype to instance
20 | utils.extend(instance, Axios.prototype, context);
21 |
22 | // Copy context to instance
23 | utils.extend(instance, context);
24 |
25 | return instance;
26 | }
27 |
28 | // Create the default instance to be exported
29 | var axios = createInstance(defaults);
30 |
31 | // Expose Axios class to allow class inheritance
32 | axios.Axios = Axios;
33 |
34 | // Factory for creating new instances
35 | axios.create = function create(instanceConfig) {
36 | return createInstance(mergeConfig(axios.defaults, instanceConfig));
37 | };
38 |
39 | // Expose Cancel & CancelToken
40 | axios.Cancel = require('./cancel/Cancel');
41 | axios.CancelToken = require('./cancel/CancelToken');
42 | axios.isCancel = require('./cancel/isCancel');
43 |
44 | // Expose all/spread
45 | axios.all = function all(promises) {
46 | return Promise.all(promises);
47 | };
48 | axios.spread = require('./helpers/spread');
49 |
50 | // Expose isAxiosError
51 | axios.isAxiosError = require('./helpers/isAxiosError');
52 |
53 | module.exports = axios;
54 |
55 | // Allow use of default import syntax in TypeScript
56 | module.exports.default = axios;
57 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/cancel/Cancel.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * A `Cancel` is an object that is thrown when an operation is canceled.
5 | *
6 | * @class
7 | * @param {string=} message The message.
8 | */
9 | function Cancel(message) {
10 | this.message = message;
11 | }
12 |
13 | Cancel.prototype.toString = function toString() {
14 | return 'Cancel' + (this.message ? ': ' + this.message : '');
15 | };
16 |
17 | Cancel.prototype.__CANCEL__ = true;
18 |
19 | module.exports = Cancel;
20 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/cancel/CancelToken.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Cancel = require('./Cancel');
4 |
5 | /**
6 | * A `CancelToken` is an object that can be used to request cancellation of an operation.
7 | *
8 | * @class
9 | * @param {Function} executor The executor function.
10 | */
11 | function CancelToken(executor) {
12 | if (typeof executor !== 'function') {
13 | throw new TypeError('executor must be a function.');
14 | }
15 |
16 | var resolvePromise;
17 | this.promise = new Promise(function promiseExecutor(resolve) {
18 | resolvePromise = resolve;
19 | });
20 |
21 | var token = this;
22 | executor(function cancel(message) {
23 | if (token.reason) {
24 | // Cancellation has already been requested
25 | return;
26 | }
27 |
28 | token.reason = new Cancel(message);
29 | resolvePromise(token.reason);
30 | });
31 | }
32 |
33 | /**
34 | * Throws a `Cancel` if cancellation has been requested.
35 | */
36 | CancelToken.prototype.throwIfRequested = function throwIfRequested() {
37 | if (this.reason) {
38 | throw this.reason;
39 | }
40 | };
41 |
42 | /**
43 | * Returns an object that contains a new `CancelToken` and a function that, when called,
44 | * cancels the `CancelToken`.
45 | */
46 | CancelToken.source = function source() {
47 | var cancel;
48 | var token = new CancelToken(function executor(c) {
49 | cancel = c;
50 | });
51 | return {
52 | token: token,
53 | cancel: cancel
54 | };
55 | };
56 |
57 | module.exports = CancelToken;
58 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/cancel/isCancel.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function isCancel(value) {
4 | return !!(value && value.__CANCEL__);
5 | };
6 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/Axios.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 | var buildURL = require('../helpers/buildURL');
5 | var InterceptorManager = require('./InterceptorManager');
6 | var dispatchRequest = require('./dispatchRequest');
7 | var mergeConfig = require('./mergeConfig');
8 |
9 | /**
10 | * Create a new instance of Axios
11 | *
12 | * @param {Object} instanceConfig The default config for the instance
13 | */
14 | function Axios(instanceConfig) {
15 | this.defaults = instanceConfig;
16 | this.interceptors = {
17 | request: new InterceptorManager(),
18 | response: new InterceptorManager()
19 | };
20 | }
21 |
22 | /**
23 | * Dispatch a request
24 | *
25 | * @param {Object} config The config specific for this request (merged with this.defaults)
26 | */
27 | Axios.prototype.request = function request(config) {
28 | /*eslint no-param-reassign:0*/
29 | // Allow for axios('example/url'[, config]) a la fetch API
30 | if (typeof config === 'string') {
31 | config = arguments[1] || {};
32 | config.url = arguments[0];
33 | } else {
34 | config = config || {};
35 | }
36 |
37 | config = mergeConfig(this.defaults, config);
38 |
39 | // Set config.method
40 | if (config.method) {
41 | config.method = config.method.toLowerCase();
42 | } else if (this.defaults.method) {
43 | config.method = this.defaults.method.toLowerCase();
44 | } else {
45 | config.method = 'get';
46 | }
47 |
48 | // Hook up interceptors middleware
49 | var chain = [dispatchRequest, undefined];
50 | var promise = Promise.resolve(config);
51 |
52 | this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
53 | chain.unshift(interceptor.fulfilled, interceptor.rejected);
54 | });
55 |
56 | this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
57 | chain.push(interceptor.fulfilled, interceptor.rejected);
58 | });
59 |
60 | while (chain.length) {
61 | promise = promise.then(chain.shift(), chain.shift());
62 | }
63 |
64 | return promise;
65 | };
66 |
67 | Axios.prototype.getUri = function getUri(config) {
68 | config = mergeConfig(this.defaults, config);
69 | return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
70 | };
71 |
72 | // Provide aliases for supported request methods
73 | utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
74 | /*eslint func-names:0*/
75 | Axios.prototype[method] = function(url, config) {
76 | return this.request(mergeConfig(config || {}, {
77 | method: method,
78 | url: url,
79 | data: (config || {}).data
80 | }));
81 | };
82 | });
83 |
84 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
85 | /*eslint func-names:0*/
86 | Axios.prototype[method] = function(url, data, config) {
87 | return this.request(mergeConfig(config || {}, {
88 | method: method,
89 | url: url,
90 | data: data
91 | }));
92 | };
93 | });
94 |
95 | module.exports = Axios;
96 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/InterceptorManager.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 |
5 | function InterceptorManager() {
6 | this.handlers = [];
7 | }
8 |
9 | /**
10 | * Add a new interceptor to the stack
11 | *
12 | * @param {Function} fulfilled The function to handle `then` for a `Promise`
13 | * @param {Function} rejected The function to handle `reject` for a `Promise`
14 | *
15 | * @return {Number} An ID used to remove interceptor later
16 | */
17 | InterceptorManager.prototype.use = function use(fulfilled, rejected) {
18 | this.handlers.push({
19 | fulfilled: fulfilled,
20 | rejected: rejected
21 | });
22 | return this.handlers.length - 1;
23 | };
24 |
25 | /**
26 | * Remove an interceptor from the stack
27 | *
28 | * @param {Number} id The ID that was returned by `use`
29 | */
30 | InterceptorManager.prototype.eject = function eject(id) {
31 | if (this.handlers[id]) {
32 | this.handlers[id] = null;
33 | }
34 | };
35 |
36 | /**
37 | * Iterate over all the registered interceptors
38 | *
39 | * This method is particularly useful for skipping over any
40 | * interceptors that may have become `null` calling `eject`.
41 | *
42 | * @param {Function} fn The function to call for each interceptor
43 | */
44 | InterceptorManager.prototype.forEach = function forEach(fn) {
45 | utils.forEach(this.handlers, function forEachHandler(h) {
46 | if (h !== null) {
47 | fn(h);
48 | }
49 | });
50 | };
51 |
52 | module.exports = InterceptorManager;
53 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/README.md:
--------------------------------------------------------------------------------
1 | # axios // core
2 |
3 | The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
4 |
5 | - Dispatching requests
6 | - Managing interceptors
7 | - Handling config
8 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/buildFullPath.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var isAbsoluteURL = require('../helpers/isAbsoluteURL');
4 | var combineURLs = require('../helpers/combineURLs');
5 |
6 | /**
7 | * Creates a new URL by combining the baseURL with the requestedURL,
8 | * only when the requestedURL is not already an absolute URL.
9 | * If the requestURL is absolute, this function returns the requestedURL untouched.
10 | *
11 | * @param {string} baseURL The base URL
12 | * @param {string} requestedURL Absolute or relative URL to combine
13 | * @returns {string} The combined full path
14 | */
15 | module.exports = function buildFullPath(baseURL, requestedURL) {
16 | if (baseURL && !isAbsoluteURL(requestedURL)) {
17 | return combineURLs(baseURL, requestedURL);
18 | }
19 | return requestedURL;
20 | };
21 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/createError.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var enhanceError = require('./enhanceError');
4 |
5 | /**
6 | * Create an Error with the specified message, config, error code, request and response.
7 | *
8 | * @param {string} message The error message.
9 | * @param {Object} config The config.
10 | * @param {string} [code] The error code (for example, 'ECONNABORTED').
11 | * @param {Object} [request] The request.
12 | * @param {Object} [response] The response.
13 | * @returns {Error} The created error.
14 | */
15 | module.exports = function createError(message, config, code, request, response) {
16 | var error = new Error(message);
17 | return enhanceError(error, config, code, request, response);
18 | };
19 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/dispatchRequest.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 | var transformData = require('./transformData');
5 | var isCancel = require('../cancel/isCancel');
6 | var defaults = require('../defaults');
7 |
8 | /**
9 | * Throws a `Cancel` if cancellation has been requested.
10 | */
11 | function throwIfCancellationRequested(config) {
12 | if (config.cancelToken) {
13 | config.cancelToken.throwIfRequested();
14 | }
15 | }
16 |
17 | /**
18 | * Dispatch a request to the server using the configured adapter.
19 | *
20 | * @param {object} config The config that is to be used for the request
21 | * @returns {Promise} The Promise to be fulfilled
22 | */
23 | module.exports = function dispatchRequest(config) {
24 | throwIfCancellationRequested(config);
25 |
26 | // Ensure headers exist
27 | config.headers = config.headers || {};
28 |
29 | // Transform request data
30 | config.data = transformData(
31 | config.data,
32 | config.headers,
33 | config.transformRequest
34 | );
35 |
36 | // Flatten headers
37 | config.headers = utils.merge(
38 | config.headers.common || {},
39 | config.headers[config.method] || {},
40 | config.headers
41 | );
42 |
43 | utils.forEach(
44 | ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
45 | function cleanHeaderConfig(method) {
46 | delete config.headers[method];
47 | }
48 | );
49 |
50 | var adapter = config.adapter || defaults.adapter;
51 |
52 | return adapter(config).then(function onAdapterResolution(response) {
53 | throwIfCancellationRequested(config);
54 |
55 | // Transform response data
56 | response.data = transformData(
57 | response.data,
58 | response.headers,
59 | config.transformResponse
60 | );
61 |
62 | return response;
63 | }, function onAdapterRejection(reason) {
64 | if (!isCancel(reason)) {
65 | throwIfCancellationRequested(config);
66 |
67 | // Transform response data
68 | if (reason && reason.response) {
69 | reason.response.data = transformData(
70 | reason.response.data,
71 | reason.response.headers,
72 | config.transformResponse
73 | );
74 | }
75 | }
76 |
77 | return Promise.reject(reason);
78 | });
79 | };
80 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/enhanceError.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Update an Error with the specified config, error code, and response.
5 | *
6 | * @param {Error} error The error to update.
7 | * @param {Object} config The config.
8 | * @param {string} [code] The error code (for example, 'ECONNABORTED').
9 | * @param {Object} [request] The request.
10 | * @param {Object} [response] The response.
11 | * @returns {Error} The error.
12 | */
13 | module.exports = function enhanceError(error, config, code, request, response) {
14 | error.config = config;
15 | if (code) {
16 | error.code = code;
17 | }
18 |
19 | error.request = request;
20 | error.response = response;
21 | error.isAxiosError = true;
22 |
23 | error.toJSON = function toJSON() {
24 | return {
25 | // Standard
26 | message: this.message,
27 | name: this.name,
28 | // Microsoft
29 | description: this.description,
30 | number: this.number,
31 | // Mozilla
32 | fileName: this.fileName,
33 | lineNumber: this.lineNumber,
34 | columnNumber: this.columnNumber,
35 | stack: this.stack,
36 | // Axios
37 | config: this.config,
38 | code: this.code
39 | };
40 | };
41 | return error;
42 | };
43 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/mergeConfig.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('../utils');
4 |
5 | /**
6 | * Config-specific merge-function which creates a new config-object
7 | * by merging two configuration objects together.
8 | *
9 | * @param {Object} config1
10 | * @param {Object} config2
11 | * @returns {Object} New object resulting from merging config2 to config1
12 | */
13 | module.exports = function mergeConfig(config1, config2) {
14 | // eslint-disable-next-line no-param-reassign
15 | config2 = config2 || {};
16 | var config = {};
17 |
18 | var valueFromConfig2Keys = ['url', 'method', 'data'];
19 | var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
20 | var defaultToConfig2Keys = [
21 | 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
22 | 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
23 | 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
24 | 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
25 | 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
26 | ];
27 | var directMergeKeys = ['validateStatus'];
28 |
29 | function getMergedValue(target, source) {
30 | if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
31 | return utils.merge(target, source);
32 | } else if (utils.isPlainObject(source)) {
33 | return utils.merge({}, source);
34 | } else if (utils.isArray(source)) {
35 | return source.slice();
36 | }
37 | return source;
38 | }
39 |
40 | function mergeDeepProperties(prop) {
41 | if (!utils.isUndefined(config2[prop])) {
42 | config[prop] = getMergedValue(config1[prop], config2[prop]);
43 | } else if (!utils.isUndefined(config1[prop])) {
44 | config[prop] = getMergedValue(undefined, config1[prop]);
45 | }
46 | }
47 |
48 | utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
49 | if (!utils.isUndefined(config2[prop])) {
50 | config[prop] = getMergedValue(undefined, config2[prop]);
51 | }
52 | });
53 |
54 | utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
55 |
56 | utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
57 | if (!utils.isUndefined(config2[prop])) {
58 | config[prop] = getMergedValue(undefined, config2[prop]);
59 | } else if (!utils.isUndefined(config1[prop])) {
60 | config[prop] = getMergedValue(undefined, config1[prop]);
61 | }
62 | });
63 |
64 | utils.forEach(directMergeKeys, function merge(prop) {
65 | if (prop in config2) {
66 | config[prop] = getMergedValue(config1[prop], config2[prop]);
67 | } else if (prop in config1) {
68 | config[prop] = getMergedValue(undefined, config1[prop]);
69 | }
70 | });
71 |
72 | var axiosKeys = valueFromConfig2Keys
73 | .concat(mergeDeepPropertiesKeys)
74 | .concat(defaultToConfig2Keys)
75 | .concat(directMergeKeys);
76 |
77 | var otherKeys = Object
78 | .keys(config1)
79 | .concat(Object.keys(config2))
80 | .filter(function filterAxiosKeys(key) {
81 | return axiosKeys.indexOf(key) === -1;
82 | });
83 |
84 | utils.forEach(otherKeys, mergeDeepProperties);
85 |
86 | return config;
87 | };
88 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/settle.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var createError = require('./createError');
4 |
5 | /**
6 | * Resolve or reject a Promise based on response status.
7 | *
8 | * @param {Function} resolve A function that resolves the promise.
9 | * @param {Function} reject A function that rejects the promise.
10 | * @param {object} response The response.
11 | */
12 | module.exports = function settle(resolve, reject, response) {
13 | var validateStatus = response.config.validateStatus;
14 | if (!response.status || !validateStatus || validateStatus(response.status)) {
15 | resolve(response);
16 | } else {
17 | reject(createError(
18 | 'Request failed with status code ' + response.status,
19 | response.config,
20 | null,
21 | response.request,
22 | response
23 | ));
24 | }
25 | };
26 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/core/transformData.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 |
5 | /**
6 | * Transform the data for a request or a response
7 | *
8 | * @param {Object|String} data The data to be transformed
9 | * @param {Array} headers The headers for the request or response
10 | * @param {Array|Function} fns A single function or Array of functions
11 | * @returns {*} The resulting transformed data
12 | */
13 | module.exports = function transformData(data, headers, fns) {
14 | /*eslint no-param-reassign:0*/
15 | utils.forEach(fns, function transform(fn) {
16 | data = fn(data, headers);
17 | });
18 |
19 | return data;
20 | };
21 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/defaults.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./utils');
4 | var normalizeHeaderName = require('./helpers/normalizeHeaderName');
5 |
6 | var DEFAULT_CONTENT_TYPE = {
7 | 'Content-Type': 'application/x-www-form-urlencoded'
8 | };
9 |
10 | function setContentTypeIfUnset(headers, value) {
11 | if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
12 | headers['Content-Type'] = value;
13 | }
14 | }
15 |
16 | function getDefaultAdapter() {
17 | var adapter;
18 | if (typeof XMLHttpRequest !== 'undefined') {
19 | // For browsers use XHR adapter
20 | adapter = require('./adapters/xhr');
21 | } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
22 | // For node use HTTP adapter
23 | adapter = require('./adapters/http');
24 | }
25 | return adapter;
26 | }
27 |
28 | var defaults = {
29 | adapter: getDefaultAdapter(),
30 |
31 | transformRequest: [function transformRequest(data, headers) {
32 | normalizeHeaderName(headers, 'Accept');
33 | normalizeHeaderName(headers, 'Content-Type');
34 | if (utils.isFormData(data) ||
35 | utils.isArrayBuffer(data) ||
36 | utils.isBuffer(data) ||
37 | utils.isStream(data) ||
38 | utils.isFile(data) ||
39 | utils.isBlob(data)
40 | ) {
41 | return data;
42 | }
43 | if (utils.isArrayBufferView(data)) {
44 | return data.buffer;
45 | }
46 | if (utils.isURLSearchParams(data)) {
47 | setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
48 | return data.toString();
49 | }
50 | if (utils.isObject(data)) {
51 | setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
52 | return JSON.stringify(data);
53 | }
54 | return data;
55 | }],
56 |
57 | transformResponse: [function transformResponse(data) {
58 | /*eslint no-param-reassign:0*/
59 | if (typeof data === 'string') {
60 | try {
61 | data = JSON.parse(data);
62 | } catch (e) { /* Ignore */ }
63 | }
64 | return data;
65 | }],
66 |
67 | /**
68 | * A timeout in milliseconds to abort a request. If set to 0 (default) a
69 | * timeout is not created.
70 | */
71 | timeout: 0,
72 |
73 | xsrfCookieName: 'XSRF-TOKEN',
74 | xsrfHeaderName: 'X-XSRF-TOKEN',
75 |
76 | maxContentLength: -1,
77 | maxBodyLength: -1,
78 |
79 | validateStatus: function validateStatus(status) {
80 | return status >= 200 && status < 300;
81 | }
82 | };
83 |
84 | defaults.headers = {
85 | common: {
86 | 'Accept': 'application/json, text/plain, */*'
87 | }
88 | };
89 |
90 | utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
91 | defaults.headers[method] = {};
92 | });
93 |
94 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
95 | defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
96 | });
97 |
98 | module.exports = defaults;
99 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/README.md:
--------------------------------------------------------------------------------
1 | # axios // helpers
2 |
3 | The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like:
4 |
5 | - Browser polyfills
6 | - Managing cookies
7 | - Parsing HTTP headers
8 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/bind.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function bind(fn, thisArg) {
4 | return function wrap() {
5 | var args = new Array(arguments.length);
6 | for (var i = 0; i < args.length; i++) {
7 | args[i] = arguments[i];
8 | }
9 | return fn.apply(thisArg, args);
10 | };
11 | };
12 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/buildURL.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 |
5 | function encode(val) {
6 | return encodeURIComponent(val).
7 | replace(/%3A/gi, ':').
8 | replace(/%24/g, '$').
9 | replace(/%2C/gi, ',').
10 | replace(/%20/g, '+').
11 | replace(/%5B/gi, '[').
12 | replace(/%5D/gi, ']');
13 | }
14 |
15 | /**
16 | * Build a URL by appending params to the end
17 | *
18 | * @param {string} url The base of the url (e.g., http://www.google.com)
19 | * @param {object} [params] The params to be appended
20 | * @returns {string} The formatted url
21 | */
22 | module.exports = function buildURL(url, params, paramsSerializer) {
23 | /*eslint no-param-reassign:0*/
24 | if (!params) {
25 | return url;
26 | }
27 |
28 | var serializedParams;
29 | if (paramsSerializer) {
30 | serializedParams = paramsSerializer(params);
31 | } else if (utils.isURLSearchParams(params)) {
32 | serializedParams = params.toString();
33 | } else {
34 | var parts = [];
35 |
36 | utils.forEach(params, function serialize(val, key) {
37 | if (val === null || typeof val === 'undefined') {
38 | return;
39 | }
40 |
41 | if (utils.isArray(val)) {
42 | key = key + '[]';
43 | } else {
44 | val = [val];
45 | }
46 |
47 | utils.forEach(val, function parseValue(v) {
48 | if (utils.isDate(v)) {
49 | v = v.toISOString();
50 | } else if (utils.isObject(v)) {
51 | v = JSON.stringify(v);
52 | }
53 | parts.push(encode(key) + '=' + encode(v));
54 | });
55 | });
56 |
57 | serializedParams = parts.join('&');
58 | }
59 |
60 | if (serializedParams) {
61 | var hashmarkIndex = url.indexOf('#');
62 | if (hashmarkIndex !== -1) {
63 | url = url.slice(0, hashmarkIndex);
64 | }
65 |
66 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
67 | }
68 |
69 | return url;
70 | };
71 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/combineURLs.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Creates a new URL by combining the specified URLs
5 | *
6 | * @param {string} baseURL The base URL
7 | * @param {string} relativeURL The relative URL
8 | * @returns {string} The combined URL
9 | */
10 | module.exports = function combineURLs(baseURL, relativeURL) {
11 | return relativeURL
12 | ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
13 | : baseURL;
14 | };
15 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/cookies.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 |
5 | module.exports = (
6 | utils.isStandardBrowserEnv() ?
7 |
8 | // Standard browser envs support document.cookie
9 | (function standardBrowserEnv() {
10 | return {
11 | write: function write(name, value, expires, path, domain, secure) {
12 | var cookie = [];
13 | cookie.push(name + '=' + encodeURIComponent(value));
14 |
15 | if (utils.isNumber(expires)) {
16 | cookie.push('expires=' + new Date(expires).toGMTString());
17 | }
18 |
19 | if (utils.isString(path)) {
20 | cookie.push('path=' + path);
21 | }
22 |
23 | if (utils.isString(domain)) {
24 | cookie.push('domain=' + domain);
25 | }
26 |
27 | if (secure === true) {
28 | cookie.push('secure');
29 | }
30 |
31 | document.cookie = cookie.join('; ');
32 | },
33 |
34 | read: function read(name) {
35 | var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36 | return (match ? decodeURIComponent(match[3]) : null);
37 | },
38 |
39 | remove: function remove(name) {
40 | this.write(name, '', Date.now() - 86400000);
41 | }
42 | };
43 | })() :
44 |
45 | // Non standard browser env (web workers, react-native) lack needed support.
46 | (function nonStandardBrowserEnv() {
47 | return {
48 | write: function write() {},
49 | read: function read() { return null; },
50 | remove: function remove() {}
51 | };
52 | })()
53 | );
54 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/deprecatedMethod.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*eslint no-console:0*/
4 |
5 | /**
6 | * Supply a warning to the developer that a method they are using
7 | * has been deprecated.
8 | *
9 | * @param {string} method The name of the deprecated method
10 | * @param {string} [instead] The alternate method to use if applicable
11 | * @param {string} [docs] The documentation URL to get further details
12 | */
13 | module.exports = function deprecatedMethod(method, instead, docs) {
14 | try {
15 | console.warn(
16 | 'DEPRECATED method `' + method + '`.' +
17 | (instead ? ' Use `' + instead + '` instead.' : '') +
18 | ' This method will be removed in a future release.');
19 |
20 | if (docs) {
21 | console.warn('For more information about usage see ' + docs);
22 | }
23 | } catch (e) { /* Ignore */ }
24 | };
25 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/isAbsoluteURL.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Determines whether the specified URL is absolute
5 | *
6 | * @param {string} url The URL to test
7 | * @returns {boolean} True if the specified URL is absolute, otherwise false
8 | */
9 | module.exports = function isAbsoluteURL(url) {
10 | // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL).
11 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
12 | // by any combination of letters, digits, plus, period, or hyphen.
13 | return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
14 | };
15 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/isAxiosError.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Determines whether the payload is an error thrown by Axios
5 | *
6 | * @param {*} payload The value to test
7 | * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
8 | */
9 | module.exports = function isAxiosError(payload) {
10 | return (typeof payload === 'object') && (payload.isAxiosError === true);
11 | };
12 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/isURLSameOrigin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 |
5 | module.exports = (
6 | utils.isStandardBrowserEnv() ?
7 |
8 | // Standard browser envs have full support of the APIs needed to test
9 | // whether the request URL is of the same origin as current location.
10 | (function standardBrowserEnv() {
11 | var msie = /(msie|trident)/i.test(navigator.userAgent);
12 | var urlParsingNode = document.createElement('a');
13 | var originURL;
14 |
15 | /**
16 | * Parse a URL to discover it's components
17 | *
18 | * @param {String} url The URL to be parsed
19 | * @returns {Object}
20 | */
21 | function resolveURL(url) {
22 | var href = url;
23 |
24 | if (msie) {
25 | // IE needs attribute set twice to normalize properties
26 | urlParsingNode.setAttribute('href', href);
27 | href = urlParsingNode.href;
28 | }
29 |
30 | urlParsingNode.setAttribute('href', href);
31 |
32 | // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33 | return {
34 | href: urlParsingNode.href,
35 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36 | host: urlParsingNode.host,
37 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39 | hostname: urlParsingNode.hostname,
40 | port: urlParsingNode.port,
41 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42 | urlParsingNode.pathname :
43 | '/' + urlParsingNode.pathname
44 | };
45 | }
46 |
47 | originURL = resolveURL(window.location.href);
48 |
49 | /**
50 | * Determine if a URL shares the same origin as the current location
51 | *
52 | * @param {String} requestURL The URL to test
53 | * @returns {boolean} True if URL shares the same origin, otherwise false
54 | */
55 | return function isURLSameOrigin(requestURL) {
56 | var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57 | return (parsed.protocol === originURL.protocol &&
58 | parsed.host === originURL.host);
59 | };
60 | })() :
61 |
62 | // Non standard browser envs (web workers, react-native) lack needed support.
63 | (function nonStandardBrowserEnv() {
64 | return function isURLSameOrigin() {
65 | return true;
66 | };
67 | })()
68 | );
69 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/normalizeHeaderName.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('../utils');
4 |
5 | module.exports = function normalizeHeaderName(headers, normalizedName) {
6 | utils.forEach(headers, function processHeader(value, name) {
7 | if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
8 | headers[normalizedName] = value;
9 | delete headers[name];
10 | }
11 | });
12 | };
13 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/parseHeaders.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var utils = require('./../utils');
4 |
5 | // Headers whose duplicates are ignored by node
6 | // c.f. https://nodejs.org/api/http.html#http_message_headers
7 | var ignoreDuplicateOf = [
8 | 'age', 'authorization', 'content-length', 'content-type', 'etag',
9 | 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
10 | 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
11 | 'referer', 'retry-after', 'user-agent'
12 | ];
13 |
14 | /**
15 | * Parse headers into an object
16 | *
17 | * ```
18 | * Date: Wed, 27 Aug 2014 08:58:49 GMT
19 | * Content-Type: application/json
20 | * Connection: keep-alive
21 | * Transfer-Encoding: chunked
22 | * ```
23 | *
24 | * @param {String} headers Headers needing to be parsed
25 | * @returns {Object} Headers parsed into an object
26 | */
27 | module.exports = function parseHeaders(headers) {
28 | var parsed = {};
29 | var key;
30 | var val;
31 | var i;
32 |
33 | if (!headers) { return parsed; }
34 |
35 | utils.forEach(headers.split('\n'), function parser(line) {
36 | i = line.indexOf(':');
37 | key = utils.trim(line.substr(0, i)).toLowerCase();
38 | val = utils.trim(line.substr(i + 1));
39 |
40 | if (key) {
41 | if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
42 | return;
43 | }
44 | if (key === 'set-cookie') {
45 | parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
46 | } else {
47 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
48 | }
49 | }
50 | });
51 |
52 | return parsed;
53 | };
54 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/helpers/spread.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Syntactic sugar for invoking a function and expanding an array for arguments.
5 | *
6 | * Common use case would be to use `Function.prototype.apply`.
7 | *
8 | * ```js
9 | * function f(x, y, z) {}
10 | * var args = [1, 2, 3];
11 | * f.apply(null, args);
12 | * ```
13 | *
14 | * With `spread` this example can be re-written.
15 | *
16 | * ```js
17 | * spread(function(x, y, z) {})([1, 2, 3]);
18 | * ```
19 | *
20 | * @param {Function} callback
21 | * @returns {Function}
22 | */
23 | module.exports = function spread(callback) {
24 | return function wrap(arr) {
25 | return callback.apply(null, arr);
26 | };
27 | };
28 |
--------------------------------------------------------------------------------
/node_modules/axios/lib/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var bind = require('./helpers/bind');
4 |
5 | /*global toString:true*/
6 |
7 | // utils is a library of generic helper functions non-specific to axios
8 |
9 | var toString = Object.prototype.toString;
10 |
11 | /**
12 | * Determine if a value is an Array
13 | *
14 | * @param {Object} val The value to test
15 | * @returns {boolean} True if value is an Array, otherwise false
16 | */
17 | function isArray(val) {
18 | return toString.call(val) === '[object Array]';
19 | }
20 |
21 | /**
22 | * Determine if a value is undefined
23 | *
24 | * @param {Object} val The value to test
25 | * @returns {boolean} True if the value is undefined, otherwise false
26 | */
27 | function isUndefined(val) {
28 | return typeof val === 'undefined';
29 | }
30 |
31 | /**
32 | * Determine if a value is a Buffer
33 | *
34 | * @param {Object} val The value to test
35 | * @returns {boolean} True if value is a Buffer, otherwise false
36 | */
37 | function isBuffer(val) {
38 | return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
39 | && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
40 | }
41 |
42 | /**
43 | * Determine if a value is an ArrayBuffer
44 | *
45 | * @param {Object} val The value to test
46 | * @returns {boolean} True if value is an ArrayBuffer, otherwise false
47 | */
48 | function isArrayBuffer(val) {
49 | return toString.call(val) === '[object ArrayBuffer]';
50 | }
51 |
52 | /**
53 | * Determine if a value is a FormData
54 | *
55 | * @param {Object} val The value to test
56 | * @returns {boolean} True if value is an FormData, otherwise false
57 | */
58 | function isFormData(val) {
59 | return (typeof FormData !== 'undefined') && (val instanceof FormData);
60 | }
61 |
62 | /**
63 | * Determine if a value is a view on an ArrayBuffer
64 | *
65 | * @param {Object} val The value to test
66 | * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
67 | */
68 | function isArrayBufferView(val) {
69 | var result;
70 | if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
71 | result = ArrayBuffer.isView(val);
72 | } else {
73 | result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
74 | }
75 | return result;
76 | }
77 |
78 | /**
79 | * Determine if a value is a String
80 | *
81 | * @param {Object} val The value to test
82 | * @returns {boolean} True if value is a String, otherwise false
83 | */
84 | function isString(val) {
85 | return typeof val === 'string';
86 | }
87 |
88 | /**
89 | * Determine if a value is a Number
90 | *
91 | * @param {Object} val The value to test
92 | * @returns {boolean} True if value is a Number, otherwise false
93 | */
94 | function isNumber(val) {
95 | return typeof val === 'number';
96 | }
97 |
98 | /**
99 | * Determine if a value is an Object
100 | *
101 | * @param {Object} val The value to test
102 | * @returns {boolean} True if value is an Object, otherwise false
103 | */
104 | function isObject(val) {
105 | return val !== null && typeof val === 'object';
106 | }
107 |
108 | /**
109 | * Determine if a value is a plain Object
110 | *
111 | * @param {Object} val The value to test
112 | * @return {boolean} True if value is a plain Object, otherwise false
113 | */
114 | function isPlainObject(val) {
115 | if (toString.call(val) !== '[object Object]') {
116 | return false;
117 | }
118 |
119 | var prototype = Object.getPrototypeOf(val);
120 | return prototype === null || prototype === Object.prototype;
121 | }
122 |
123 | /**
124 | * Determine if a value is a Date
125 | *
126 | * @param {Object} val The value to test
127 | * @returns {boolean} True if value is a Date, otherwise false
128 | */
129 | function isDate(val) {
130 | return toString.call(val) === '[object Date]';
131 | }
132 |
133 | /**
134 | * Determine if a value is a File
135 | *
136 | * @param {Object} val The value to test
137 | * @returns {boolean} True if value is a File, otherwise false
138 | */
139 | function isFile(val) {
140 | return toString.call(val) === '[object File]';
141 | }
142 |
143 | /**
144 | * Determine if a value is a Blob
145 | *
146 | * @param {Object} val The value to test
147 | * @returns {boolean} True if value is a Blob, otherwise false
148 | */
149 | function isBlob(val) {
150 | return toString.call(val) === '[object Blob]';
151 | }
152 |
153 | /**
154 | * Determine if a value is a Function
155 | *
156 | * @param {Object} val The value to test
157 | * @returns {boolean} True if value is a Function, otherwise false
158 | */
159 | function isFunction(val) {
160 | return toString.call(val) === '[object Function]';
161 | }
162 |
163 | /**
164 | * Determine if a value is a Stream
165 | *
166 | * @param {Object} val The value to test
167 | * @returns {boolean} True if value is a Stream, otherwise false
168 | */
169 | function isStream(val) {
170 | return isObject(val) && isFunction(val.pipe);
171 | }
172 |
173 | /**
174 | * Determine if a value is a URLSearchParams object
175 | *
176 | * @param {Object} val The value to test
177 | * @returns {boolean} True if value is a URLSearchParams object, otherwise false
178 | */
179 | function isURLSearchParams(val) {
180 | return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
181 | }
182 |
183 | /**
184 | * Trim excess whitespace off the beginning and end of a string
185 | *
186 | * @param {String} str The String to trim
187 | * @returns {String} The String freed of excess whitespace
188 | */
189 | function trim(str) {
190 | return str.replace(/^\s*/, '').replace(/\s*$/, '');
191 | }
192 |
193 | /**
194 | * Determine if we're running in a standard browser environment
195 | *
196 | * This allows axios to run in a web worker, and react-native.
197 | * Both environments support XMLHttpRequest, but not fully standard globals.
198 | *
199 | * web workers:
200 | * typeof window -> undefined
201 | * typeof document -> undefined
202 | *
203 | * react-native:
204 | * navigator.product -> 'ReactNative'
205 | * nativescript
206 | * navigator.product -> 'NativeScript' or 'NS'
207 | */
208 | function isStandardBrowserEnv() {
209 | if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
210 | navigator.product === 'NativeScript' ||
211 | navigator.product === 'NS')) {
212 | return false;
213 | }
214 | return (
215 | typeof window !== 'undefined' &&
216 | typeof document !== 'undefined'
217 | );
218 | }
219 |
220 | /**
221 | * Iterate over an Array or an Object invoking a function for each item.
222 | *
223 | * If `obj` is an Array callback will be called passing
224 | * the value, index, and complete array for each item.
225 | *
226 | * If 'obj' is an Object callback will be called passing
227 | * the value, key, and complete object for each property.
228 | *
229 | * @param {Object|Array} obj The object to iterate
230 | * @param {Function} fn The callback to invoke for each item
231 | */
232 | function forEach(obj, fn) {
233 | // Don't bother if no value provided
234 | if (obj === null || typeof obj === 'undefined') {
235 | return;
236 | }
237 |
238 | // Force an array if not already something iterable
239 | if (typeof obj !== 'object') {
240 | /*eslint no-param-reassign:0*/
241 | obj = [obj];
242 | }
243 |
244 | if (isArray(obj)) {
245 | // Iterate over array values
246 | for (var i = 0, l = obj.length; i < l; i++) {
247 | fn.call(null, obj[i], i, obj);
248 | }
249 | } else {
250 | // Iterate over object keys
251 | for (var key in obj) {
252 | if (Object.prototype.hasOwnProperty.call(obj, key)) {
253 | fn.call(null, obj[key], key, obj);
254 | }
255 | }
256 | }
257 | }
258 |
259 | /**
260 | * Accepts varargs expecting each argument to be an object, then
261 | * immutably merges the properties of each object and returns result.
262 | *
263 | * When multiple objects contain the same key the later object in
264 | * the arguments list will take precedence.
265 | *
266 | * Example:
267 | *
268 | * ```js
269 | * var result = merge({foo: 123}, {foo: 456});
270 | * console.log(result.foo); // outputs 456
271 | * ```
272 | *
273 | * @param {Object} obj1 Object to merge
274 | * @returns {Object} Result of all merge properties
275 | */
276 | function merge(/* obj1, obj2, obj3, ... */) {
277 | var result = {};
278 | function assignValue(val, key) {
279 | if (isPlainObject(result[key]) && isPlainObject(val)) {
280 | result[key] = merge(result[key], val);
281 | } else if (isPlainObject(val)) {
282 | result[key] = merge({}, val);
283 | } else if (isArray(val)) {
284 | result[key] = val.slice();
285 | } else {
286 | result[key] = val;
287 | }
288 | }
289 |
290 | for (var i = 0, l = arguments.length; i < l; i++) {
291 | forEach(arguments[i], assignValue);
292 | }
293 | return result;
294 | }
295 |
296 | /**
297 | * Extends object a by mutably adding to it the properties of object b.
298 | *
299 | * @param {Object} a The object to be extended
300 | * @param {Object} b The object to copy properties from
301 | * @param {Object} thisArg The object to bind function to
302 | * @return {Object} The resulting value of object a
303 | */
304 | function extend(a, b, thisArg) {
305 | forEach(b, function assignValue(val, key) {
306 | if (thisArg && typeof val === 'function') {
307 | a[key] = bind(val, thisArg);
308 | } else {
309 | a[key] = val;
310 | }
311 | });
312 | return a;
313 | }
314 |
315 | /**
316 | * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
317 | *
318 | * @param {string} content with BOM
319 | * @return {string} content value without BOM
320 | */
321 | function stripBOM(content) {
322 | if (content.charCodeAt(0) === 0xFEFF) {
323 | content = content.slice(1);
324 | }
325 | return content;
326 | }
327 |
328 | module.exports = {
329 | isArray: isArray,
330 | isArrayBuffer: isArrayBuffer,
331 | isBuffer: isBuffer,
332 | isFormData: isFormData,
333 | isArrayBufferView: isArrayBufferView,
334 | isString: isString,
335 | isNumber: isNumber,
336 | isObject: isObject,
337 | isPlainObject: isPlainObject,
338 | isUndefined: isUndefined,
339 | isDate: isDate,
340 | isFile: isFile,
341 | isBlob: isBlob,
342 | isFunction: isFunction,
343 | isStream: isStream,
344 | isURLSearchParams: isURLSearchParams,
345 | isStandardBrowserEnv: isStandardBrowserEnv,
346 | forEach: forEach,
347 | merge: merge,
348 | extend: extend,
349 | trim: trim,
350 | stripBOM: stripBOM
351 | };
352 |
--------------------------------------------------------------------------------
/node_modules/axios/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "_from": "axios",
3 | "_id": "axios@0.21.1",
4 | "_inBundle": false,
5 | "_integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
6 | "_location": "/axios",
7 | "_phantomChildren": {},
8 | "_requested": {
9 | "type": "tag",
10 | "registry": true,
11 | "raw": "axios",
12 | "name": "axios",
13 | "escapedName": "axios",
14 | "rawSpec": "",
15 | "saveSpec": null,
16 | "fetchSpec": "latest"
17 | },
18 | "_requiredBy": [
19 | "#USER",
20 | "/"
21 | ],
22 | "_resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
23 | "_shasum": "22563481962f4d6bde9a76d516ef0e5d3c09b2b8",
24 | "_spec": "axios",
25 | "_where": "/home/andy/GitHubCloned/Requests-API-in-js",
26 | "author": {
27 | "name": "Matt Zabriskie"
28 | },
29 | "browser": {
30 | "./lib/adapters/http.js": "./lib/adapters/xhr.js"
31 | },
32 | "bugs": {
33 | "url": "https://github.com/axios/axios/issues"
34 | },
35 | "bundleDependencies": false,
36 | "bundlesize": [
37 | {
38 | "path": "./dist/axios.min.js",
39 | "threshold": "5kB"
40 | }
41 | ],
42 | "dependencies": {
43 | "follow-redirects": "^1.10.0"
44 | },
45 | "deprecated": false,
46 | "description": "Promise based HTTP client for the browser and node.js",
47 | "devDependencies": {
48 | "bundlesize": "^0.17.0",
49 | "coveralls": "^3.0.0",
50 | "es6-promise": "^4.2.4",
51 | "grunt": "^1.0.2",
52 | "grunt-banner": "^0.6.0",
53 | "grunt-cli": "^1.2.0",
54 | "grunt-contrib-clean": "^1.1.0",
55 | "grunt-contrib-watch": "^1.0.0",
56 | "grunt-eslint": "^20.1.0",
57 | "grunt-karma": "^2.0.0",
58 | "grunt-mocha-test": "^0.13.3",
59 | "grunt-ts": "^6.0.0-beta.19",
60 | "grunt-webpack": "^1.0.18",
61 | "istanbul-instrumenter-loader": "^1.0.0",
62 | "jasmine-core": "^2.4.1",
63 | "karma": "^1.3.0",
64 | "karma-chrome-launcher": "^2.2.0",
65 | "karma-coverage": "^1.1.1",
66 | "karma-firefox-launcher": "^1.1.0",
67 | "karma-jasmine": "^1.1.1",
68 | "karma-jasmine-ajax": "^0.1.13",
69 | "karma-opera-launcher": "^1.0.0",
70 | "karma-safari-launcher": "^1.0.0",
71 | "karma-sauce-launcher": "^1.2.0",
72 | "karma-sinon": "^1.0.5",
73 | "karma-sourcemap-loader": "^0.3.7",
74 | "karma-webpack": "^1.7.0",
75 | "load-grunt-tasks": "^3.5.2",
76 | "minimist": "^1.2.0",
77 | "mocha": "^5.2.0",
78 | "sinon": "^4.5.0",
79 | "typescript": "^2.8.1",
80 | "url-search-params": "^0.10.0",
81 | "webpack": "^1.13.1",
82 | "webpack-dev-server": "^1.14.1"
83 | },
84 | "homepage": "https://github.com/axios/axios",
85 | "jsdelivr": "dist/axios.min.js",
86 | "keywords": [
87 | "xhr",
88 | "http",
89 | "ajax",
90 | "promise",
91 | "node"
92 | ],
93 | "license": "MIT",
94 | "main": "index.js",
95 | "name": "axios",
96 | "repository": {
97 | "type": "git",
98 | "url": "git+https://github.com/axios/axios.git"
99 | },
100 | "scripts": {
101 | "build": "NODE_ENV=production grunt build",
102 | "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
103 | "examples": "node ./examples/server.js",
104 | "fix": "eslint --fix lib/**/*.js",
105 | "postversion": "git push && git push --tags",
106 | "preversion": "npm test",
107 | "start": "node ./sandbox/server.js",
108 | "test": "grunt test && bundlesize",
109 | "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"
110 | },
111 | "typings": "./index.d.ts",
112 | "unpkg": "dist/axios.min.js",
113 | "version": "0.21.1"
114 | }
115 |
--------------------------------------------------------------------------------
/node_modules/follow-redirects/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2014–present Olivier Lalonde , James Talmage , Ruben Verborgh
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | of the Software, and to permit persons to whom the Software is furnished to do
8 | so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
18 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 |
--------------------------------------------------------------------------------
/node_modules/follow-redirects/README.md:
--------------------------------------------------------------------------------
1 | ## Follow Redirects
2 |
3 | Drop-in replacement for Node's `http` and `https` modules that automatically follows redirects.
4 |
5 | [](https://www.npmjs.com/package/follow-redirects)
6 | [](https://github.com/follow-redirects/follow-redirects/actions)
7 | [](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master)
8 | [](https://www.npmjs.com/package/follow-redirects)
9 | [](https://github.com/sponsors/RubenVerborgh)
10 |
11 | `follow-redirects` provides [request](https://nodejs.org/api/http.html#http_http_request_options_callback) and [get](https://nodejs.org/api/http.html#http_http_get_options_callback)
12 | methods that behave identically to those found on the native [http](https://nodejs.org/api/http.html#http_http_request_options_callback) and [https](https://nodejs.org/api/https.html#https_https_request_options_callback)
13 | modules, with the exception that they will seamlessly follow redirects.
14 |
15 | ```javascript
16 | const { http, https } = require('follow-redirects');
17 |
18 | http.get('http://bit.ly/900913', response => {
19 | response.on('data', chunk => {
20 | console.log(chunk);
21 | });
22 | }).on('error', err => {
23 | console.error(err);
24 | });
25 | ```
26 |
27 | You can inspect the final redirected URL through the `responseUrl` property on the `response`.
28 | If no redirection happened, `responseUrl` is the original request URL.
29 |
30 | ```javascript
31 | const request = https.request({
32 | host: 'bitly.com',
33 | path: '/UHfDGO',
34 | }, response => {
35 | console.log(response.responseUrl);
36 | // 'http://duckduckgo.com/robots.txt'
37 | });
38 | request.end();
39 | ```
40 |
41 | ## Options
42 | ### Global options
43 | Global options are set directly on the `follow-redirects` module:
44 |
45 | ```javascript
46 | const followRedirects = require('follow-redirects');
47 | followRedirects.maxRedirects = 10;
48 | followRedirects.maxBodyLength = 20 * 1024 * 1024; // 20 MB
49 | ```
50 |
51 | The following global options are supported:
52 |
53 | - `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted.
54 |
55 | - `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted.
56 |
57 | ### Per-request options
58 | Per-request options are set by passing an `options` object:
59 |
60 | ```javascript
61 | const url = require('url');
62 | const { http, https } = require('follow-redirects');
63 |
64 | const options = url.parse('http://bit.ly/900913');
65 | options.maxRedirects = 10;
66 | options.beforeRedirect = (options, { headers }) => {
67 | // Use this to adjust the request options upon redirecting,
68 | // to inspect the latest response headers,
69 | // or to cancel the request by throwing an error
70 | if (options.hostname === "example.com") {
71 | options.auth = "user:password";
72 | }
73 | };
74 | http.request(options);
75 | ```
76 |
77 | In addition to the [standard HTTP](https://nodejs.org/api/http.html#http_http_request_options_callback) and [HTTPS options](https://nodejs.org/api/https.html#https_https_request_options_callback),
78 | the following per-request options are supported:
79 | - `followRedirects` (default: `true`) – whether redirects should be followed.
80 |
81 | - `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted.
82 |
83 | - `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted.
84 |
85 | - `beforeRedirect` (default: `undefined`) – optionally change the request `options` on redirects, or abort the request by throwing an error.
86 |
87 | - `agents` (default: `undefined`) – sets the `agent` option per protocol, since HTTP and HTTPS use different agents. Example value: `{ http: new http.Agent(), https: new https.Agent() }`
88 |
89 | - `trackRedirects` (default: `false`) – whether to store the redirected response details into the `redirects` array on the response object.
90 |
91 |
92 | ### Advanced usage
93 | By default, `follow-redirects` will use the Node.js default implementations
94 | of [`http`](https://nodejs.org/api/http.html)
95 | and [`https`](https://nodejs.org/api/https.html).
96 | To enable features such as caching and/or intermediate request tracking,
97 | you might instead want to wrap `follow-redirects` around custom protocol implementations:
98 |
99 | ```javascript
100 | const { http, https } = require('follow-redirects').wrap({
101 | http: require('your-custom-http'),
102 | https: require('your-custom-https'),
103 | });
104 | ```
105 |
106 | Such custom protocols only need an implementation of the `request` method.
107 |
108 | ## Browser Usage
109 |
110 | Due to the way the browser works,
111 | the `http` and `https` browser equivalents perform redirects by default.
112 |
113 | By requiring `follow-redirects` this way:
114 | ```javascript
115 | const http = require('follow-redirects/http');
116 | const https = require('follow-redirects/https');
117 | ```
118 | you can easily tell webpack and friends to replace
119 | `follow-redirect` by the built-in versions:
120 |
121 | ```json
122 | {
123 | "follow-redirects/http" : "http",
124 | "follow-redirects/https" : "https"
125 | }
126 | ```
127 |
128 | ## Contributing
129 |
130 | Pull Requests are always welcome. Please [file an issue](https://github.com/follow-redirects/follow-redirects/issues)
131 | detailing your proposal before you invest your valuable time. Additional features and bug fixes should be accompanied
132 | by tests. You can run the test suite locally with a simple `npm test` command.
133 |
134 | ## Debug Logging
135 |
136 | `follow-redirects` uses the excellent [debug](https://www.npmjs.com/package/debug) for logging. To turn on logging
137 | set the environment variable `DEBUG=follow-redirects` for debug output from just this module. When running the test
138 | suite it is sometimes advantageous to set `DEBUG=*` to see output from the express server as well.
139 |
140 | ## Authors
141 |
142 | - [Ruben Verborgh](https://ruben.verborgh.org/)
143 | - [Olivier Lalonde](mailto:olalonde@gmail.com)
144 | - [James Talmage](mailto:james@talmage.io)
145 |
146 | ## License
147 |
148 | [MIT License](https://github.com/follow-redirects/follow-redirects/blob/master/LICENSE)
149 |
--------------------------------------------------------------------------------
/node_modules/follow-redirects/debug.js:
--------------------------------------------------------------------------------
1 | var debug;
2 |
3 | module.exports = function () {
4 | if (!debug) {
5 | try {
6 | /* eslint global-require: off */
7 | debug = require("debug")("follow-redirects");
8 | }
9 | catch (error) {
10 | debug = function () { /* */ };
11 | }
12 | }
13 | debug.apply(null, arguments);
14 | };
15 |
--------------------------------------------------------------------------------
/node_modules/follow-redirects/http.js:
--------------------------------------------------------------------------------
1 | module.exports = require("./").http;
2 |
--------------------------------------------------------------------------------
/node_modules/follow-redirects/https.js:
--------------------------------------------------------------------------------
1 | module.exports = require("./").https;
2 |
--------------------------------------------------------------------------------
/node_modules/follow-redirects/index.js:
--------------------------------------------------------------------------------
1 | var url = require("url");
2 | var URL = url.URL;
3 | var http = require("http");
4 | var https = require("https");
5 | var Writable = require("stream").Writable;
6 | var assert = require("assert");
7 | var debug = require("./debug");
8 |
9 | // Create handlers that pass events from native requests
10 | var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
11 | var eventHandlers = Object.create(null);
12 | events.forEach(function (event) {
13 | eventHandlers[event] = function (arg1, arg2, arg3) {
14 | this._redirectable.emit(event, arg1, arg2, arg3);
15 | };
16 | });
17 |
18 | // Error types with codes
19 | var RedirectionError = createErrorType(
20 | "ERR_FR_REDIRECTION_FAILURE",
21 | ""
22 | );
23 | var TooManyRedirectsError = createErrorType(
24 | "ERR_FR_TOO_MANY_REDIRECTS",
25 | "Maximum number of redirects exceeded"
26 | );
27 | var MaxBodyLengthExceededError = createErrorType(
28 | "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
29 | "Request body larger than maxBodyLength limit"
30 | );
31 | var WriteAfterEndError = createErrorType(
32 | "ERR_STREAM_WRITE_AFTER_END",
33 | "write after end"
34 | );
35 |
36 | // An HTTP(S) request that can be redirected
37 | function RedirectableRequest(options, responseCallback) {
38 | // Initialize the request
39 | Writable.call(this);
40 | this._sanitizeOptions(options);
41 | this._options = options;
42 | this._ended = false;
43 | this._ending = false;
44 | this._redirectCount = 0;
45 | this._redirects = [];
46 | this._requestBodyLength = 0;
47 | this._requestBodyBuffers = [];
48 |
49 | // Attach a callback if passed
50 | if (responseCallback) {
51 | this.on("response", responseCallback);
52 | }
53 |
54 | // React to responses of native requests
55 | var self = this;
56 | this._onNativeResponse = function (response) {
57 | self._processResponse(response);
58 | };
59 |
60 | // Perform the first request
61 | this._performRequest();
62 | }
63 | RedirectableRequest.prototype = Object.create(Writable.prototype);
64 |
65 | RedirectableRequest.prototype.abort = function () {
66 | // Abort the internal request
67 | abortRequest(this._currentRequest);
68 |
69 | // Abort this request
70 | this.emit("abort");
71 | this.removeAllListeners();
72 | };
73 |
74 | // Writes buffered data to the current native request
75 | RedirectableRequest.prototype.write = function (data, encoding, callback) {
76 | // Writing is not allowed if end has been called
77 | if (this._ending) {
78 | throw new WriteAfterEndError();
79 | }
80 |
81 | // Validate input and shift parameters if necessary
82 | if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
83 | throw new TypeError("data should be a string, Buffer or Uint8Array");
84 | }
85 | if (typeof encoding === "function") {
86 | callback = encoding;
87 | encoding = null;
88 | }
89 |
90 | // Ignore empty buffers, since writing them doesn't invoke the callback
91 | // https://github.com/nodejs/node/issues/22066
92 | if (data.length === 0) {
93 | if (callback) {
94 | callback();
95 | }
96 | return;
97 | }
98 | // Only write when we don't exceed the maximum body length
99 | if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
100 | this._requestBodyLength += data.length;
101 | this._requestBodyBuffers.push({ data: data, encoding: encoding });
102 | this._currentRequest.write(data, encoding, callback);
103 | }
104 | // Error when we exceed the maximum body length
105 | else {
106 | this.emit("error", new MaxBodyLengthExceededError());
107 | this.abort();
108 | }
109 | };
110 |
111 | // Ends the current native request
112 | RedirectableRequest.prototype.end = function (data, encoding, callback) {
113 | // Shift parameters if necessary
114 | if (typeof data === "function") {
115 | callback = data;
116 | data = encoding = null;
117 | }
118 | else if (typeof encoding === "function") {
119 | callback = encoding;
120 | encoding = null;
121 | }
122 |
123 | // Write data if needed and end
124 | if (!data) {
125 | this._ended = this._ending = true;
126 | this._currentRequest.end(null, null, callback);
127 | }
128 | else {
129 | var self = this;
130 | var currentRequest = this._currentRequest;
131 | this.write(data, encoding, function () {
132 | self._ended = true;
133 | currentRequest.end(null, null, callback);
134 | });
135 | this._ending = true;
136 | }
137 | };
138 |
139 | // Sets a header value on the current native request
140 | RedirectableRequest.prototype.setHeader = function (name, value) {
141 | this._options.headers[name] = value;
142 | this._currentRequest.setHeader(name, value);
143 | };
144 |
145 | // Clears a header value on the current native request
146 | RedirectableRequest.prototype.removeHeader = function (name) {
147 | delete this._options.headers[name];
148 | this._currentRequest.removeHeader(name);
149 | };
150 |
151 | // Global timeout for all underlying requests
152 | RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
153 | var self = this;
154 | if (callback) {
155 | this.on("timeout", callback);
156 | }
157 |
158 | function destroyOnTimeout(socket) {
159 | socket.setTimeout(msecs);
160 | socket.removeListener("timeout", socket.destroy);
161 | socket.addListener("timeout", socket.destroy);
162 | }
163 |
164 | // Sets up a timer to trigger a timeout event
165 | function startTimer(socket) {
166 | if (self._timeout) {
167 | clearTimeout(self._timeout);
168 | }
169 | self._timeout = setTimeout(function () {
170 | self.emit("timeout");
171 | clearTimer();
172 | }, msecs);
173 | destroyOnTimeout(socket);
174 | }
175 |
176 | // Prevent a timeout from triggering
177 | function clearTimer() {
178 | clearTimeout(this._timeout);
179 | if (callback) {
180 | self.removeListener("timeout", callback);
181 | }
182 | if (!this.socket) {
183 | self._currentRequest.removeListener("socket", startTimer);
184 | }
185 | }
186 |
187 | // Start the timer when the socket is opened
188 | if (this.socket) {
189 | startTimer(this.socket);
190 | }
191 | else {
192 | this._currentRequest.once("socket", startTimer);
193 | }
194 |
195 | this.on("socket", destroyOnTimeout);
196 | this.once("response", clearTimer);
197 | this.once("error", clearTimer);
198 |
199 | return this;
200 | };
201 |
202 | // Proxy all other public ClientRequest methods
203 | [
204 | "flushHeaders", "getHeader",
205 | "setNoDelay", "setSocketKeepAlive",
206 | ].forEach(function (method) {
207 | RedirectableRequest.prototype[method] = function (a, b) {
208 | return this._currentRequest[method](a, b);
209 | };
210 | });
211 |
212 | // Proxy all public ClientRequest properties
213 | ["aborted", "connection", "socket"].forEach(function (property) {
214 | Object.defineProperty(RedirectableRequest.prototype, property, {
215 | get: function () { return this._currentRequest[property]; },
216 | });
217 | });
218 |
219 | RedirectableRequest.prototype._sanitizeOptions = function (options) {
220 | // Ensure headers are always present
221 | if (!options.headers) {
222 | options.headers = {};
223 | }
224 |
225 | // Since http.request treats host as an alias of hostname,
226 | // but the url module interprets host as hostname plus port,
227 | // eliminate the host property to avoid confusion.
228 | if (options.host) {
229 | // Use hostname if set, because it has precedence
230 | if (!options.hostname) {
231 | options.hostname = options.host;
232 | }
233 | delete options.host;
234 | }
235 |
236 | // Complete the URL object when necessary
237 | if (!options.pathname && options.path) {
238 | var searchPos = options.path.indexOf("?");
239 | if (searchPos < 0) {
240 | options.pathname = options.path;
241 | }
242 | else {
243 | options.pathname = options.path.substring(0, searchPos);
244 | options.search = options.path.substring(searchPos);
245 | }
246 | }
247 | };
248 |
249 |
250 | // Executes the next native request (initial or redirect)
251 | RedirectableRequest.prototype._performRequest = function () {
252 | // Load the native protocol
253 | var protocol = this._options.protocol;
254 | var nativeProtocol = this._options.nativeProtocols[protocol];
255 | if (!nativeProtocol) {
256 | this.emit("error", new TypeError("Unsupported protocol " + protocol));
257 | return;
258 | }
259 |
260 | // If specified, use the agent corresponding to the protocol
261 | // (HTTP and HTTPS use different types of agents)
262 | if (this._options.agents) {
263 | var scheme = protocol.substr(0, protocol.length - 1);
264 | this._options.agent = this._options.agents[scheme];
265 | }
266 |
267 | // Create the native request
268 | var request = this._currentRequest =
269 | nativeProtocol.request(this._options, this._onNativeResponse);
270 | this._currentUrl = url.format(this._options);
271 |
272 | // Set up event handlers
273 | request._redirectable = this;
274 | for (var e = 0; e < events.length; e++) {
275 | request.on(events[e], eventHandlers[events[e]]);
276 | }
277 |
278 | // End a redirected request
279 | // (The first request must be ended explicitly with RedirectableRequest#end)
280 | if (this._isRedirect) {
281 | // Write the request entity and end.
282 | var i = 0;
283 | var self = this;
284 | var buffers = this._requestBodyBuffers;
285 | (function writeNext(error) {
286 | // Only write if this request has not been redirected yet
287 | /* istanbul ignore else */
288 | if (request === self._currentRequest) {
289 | // Report any write errors
290 | /* istanbul ignore if */
291 | if (error) {
292 | self.emit("error", error);
293 | }
294 | // Write the next buffer if there are still left
295 | else if (i < buffers.length) {
296 | var buffer = buffers[i++];
297 | /* istanbul ignore else */
298 | if (!request.finished) {
299 | request.write(buffer.data, buffer.encoding, writeNext);
300 | }
301 | }
302 | // End the request if `end` has been called on us
303 | else if (self._ended) {
304 | request.end();
305 | }
306 | }
307 | }());
308 | }
309 | };
310 |
311 | // Processes a response from the current native request
312 | RedirectableRequest.prototype._processResponse = function (response) {
313 | // Store the redirected response
314 | var statusCode = response.statusCode;
315 | if (this._options.trackRedirects) {
316 | this._redirects.push({
317 | url: this._currentUrl,
318 | headers: response.headers,
319 | statusCode: statusCode,
320 | });
321 | }
322 |
323 | // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
324 | // that further action needs to be taken by the user agent in order to
325 | // fulfill the request. If a Location header field is provided,
326 | // the user agent MAY automatically redirect its request to the URI
327 | // referenced by the Location field value,
328 | // even if the specific status code is not understood.
329 | var location = response.headers.location;
330 | if (location && this._options.followRedirects !== false &&
331 | statusCode >= 300 && statusCode < 400) {
332 | // Abort the current request
333 | abortRequest(this._currentRequest);
334 | // Discard the remainder of the response to avoid waiting for data
335 | response.destroy();
336 |
337 | // RFC7231§6.4: A client SHOULD detect and intervene
338 | // in cyclical redirections (i.e., "infinite" redirection loops).
339 | if (++this._redirectCount > this._options.maxRedirects) {
340 | this.emit("error", new TooManyRedirectsError());
341 | return;
342 | }
343 |
344 | // RFC7231§6.4: Automatic redirection needs to done with
345 | // care for methods not known to be safe, […]
346 | // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
347 | // the request method from POST to GET for the subsequent request.
348 | if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
349 | // RFC7231§6.4.4: The 303 (See Other) status code indicates that
350 | // the server is redirecting the user agent to a different resource […]
351 | // A user agent can perform a retrieval request targeting that URI
352 | // (a GET or HEAD request if using HTTP) […]
353 | (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
354 | this._options.method = "GET";
355 | // Drop a possible entity and headers related to it
356 | this._requestBodyBuffers = [];
357 | removeMatchingHeaders(/^content-/i, this._options.headers);
358 | }
359 |
360 | // Drop the Host header, as the redirect might lead to a different host
361 | var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) ||
362 | url.parse(this._currentUrl).hostname;
363 |
364 | // Create the redirected request
365 | var redirectUrl = url.resolve(this._currentUrl, location);
366 | debug("redirecting to", redirectUrl);
367 | this._isRedirect = true;
368 | var redirectUrlParts = url.parse(redirectUrl);
369 | Object.assign(this._options, redirectUrlParts);
370 |
371 | // Drop the Authorization header if redirecting to another host
372 | if (redirectUrlParts.hostname !== previousHostName) {
373 | removeMatchingHeaders(/^authorization$/i, this._options.headers);
374 | }
375 |
376 | // Evaluate the beforeRedirect callback
377 | if (typeof this._options.beforeRedirect === "function") {
378 | var responseDetails = { headers: response.headers };
379 | try {
380 | this._options.beforeRedirect.call(null, this._options, responseDetails);
381 | }
382 | catch (err) {
383 | this.emit("error", err);
384 | return;
385 | }
386 | this._sanitizeOptions(this._options);
387 | }
388 |
389 | // Perform the redirected request
390 | try {
391 | this._performRequest();
392 | }
393 | catch (cause) {
394 | var error = new RedirectionError("Redirected request failed: " + cause.message);
395 | error.cause = cause;
396 | this.emit("error", error);
397 | }
398 | }
399 | else {
400 | // The response is not a redirect; return it as-is
401 | response.responseUrl = this._currentUrl;
402 | response.redirects = this._redirects;
403 | this.emit("response", response);
404 |
405 | // Clean up
406 | this._requestBodyBuffers = [];
407 | }
408 | };
409 |
410 | // Wraps the key/value object of protocols with redirect functionality
411 | function wrap(protocols) {
412 | // Default settings
413 | var exports = {
414 | maxRedirects: 21,
415 | maxBodyLength: 10 * 1024 * 1024,
416 | };
417 |
418 | // Wrap each protocol
419 | var nativeProtocols = {};
420 | Object.keys(protocols).forEach(function (scheme) {
421 | var protocol = scheme + ":";
422 | var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
423 | var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
424 |
425 | // Executes a request, following redirects
426 | function request(input, options, callback) {
427 | // Parse parameters
428 | if (typeof input === "string") {
429 | var urlStr = input;
430 | try {
431 | input = urlToOptions(new URL(urlStr));
432 | }
433 | catch (err) {
434 | /* istanbul ignore next */
435 | input = url.parse(urlStr);
436 | }
437 | }
438 | else if (URL && (input instanceof URL)) {
439 | input = urlToOptions(input);
440 | }
441 | else {
442 | callback = options;
443 | options = input;
444 | input = { protocol: protocol };
445 | }
446 | if (typeof options === "function") {
447 | callback = options;
448 | options = null;
449 | }
450 |
451 | // Set defaults
452 | options = Object.assign({
453 | maxRedirects: exports.maxRedirects,
454 | maxBodyLength: exports.maxBodyLength,
455 | }, input, options);
456 | options.nativeProtocols = nativeProtocols;
457 |
458 | assert.equal(options.protocol, protocol, "protocol mismatch");
459 | debug("options", options);
460 | return new RedirectableRequest(options, callback);
461 | }
462 |
463 | // Executes a GET request, following redirects
464 | function get(input, options, callback) {
465 | var wrappedRequest = wrappedProtocol.request(input, options, callback);
466 | wrappedRequest.end();
467 | return wrappedRequest;
468 | }
469 |
470 | // Expose the properties on the wrapped protocol
471 | Object.defineProperties(wrappedProtocol, {
472 | request: { value: request, configurable: true, enumerable: true, writable: true },
473 | get: { value: get, configurable: true, enumerable: true, writable: true },
474 | });
475 | });
476 | return exports;
477 | }
478 |
479 | /* istanbul ignore next */
480 | function noop() { /* empty */ }
481 |
482 | // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
483 | function urlToOptions(urlObject) {
484 | var options = {
485 | protocol: urlObject.protocol,
486 | hostname: urlObject.hostname.startsWith("[") ?
487 | /* istanbul ignore next */
488 | urlObject.hostname.slice(1, -1) :
489 | urlObject.hostname,
490 | hash: urlObject.hash,
491 | search: urlObject.search,
492 | pathname: urlObject.pathname,
493 | path: urlObject.pathname + urlObject.search,
494 | href: urlObject.href,
495 | };
496 | if (urlObject.port !== "") {
497 | options.port = Number(urlObject.port);
498 | }
499 | return options;
500 | }
501 |
502 | function removeMatchingHeaders(regex, headers) {
503 | var lastValue;
504 | for (var header in headers) {
505 | if (regex.test(header)) {
506 | lastValue = headers[header];
507 | delete headers[header];
508 | }
509 | }
510 | return lastValue;
511 | }
512 |
513 | function createErrorType(code, defaultMessage) {
514 | function CustomError(message) {
515 | Error.captureStackTrace(this, this.constructor);
516 | this.message = message || defaultMessage;
517 | }
518 | CustomError.prototype = new Error();
519 | CustomError.prototype.constructor = CustomError;
520 | CustomError.prototype.name = "Error [" + code + "]";
521 | CustomError.prototype.code = code;
522 | return CustomError;
523 | }
524 |
525 | function abortRequest(request) {
526 | for (var e = 0; e < events.length; e++) {
527 | request.removeListener(events[e], eventHandlers[events[e]]);
528 | }
529 | request.on("error", noop);
530 | request.abort();
531 | }
532 |
533 | // Exports
534 | module.exports = wrap({ http: http, https: https });
535 | module.exports.wrap = wrap;
536 |
--------------------------------------------------------------------------------
/node_modules/follow-redirects/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "_from": "follow-redirects@^1.10.0",
3 | "_id": "follow-redirects@1.14.0",
4 | "_inBundle": false,
5 | "_integrity": "sha512-0vRwd7RKQBTt+mgu87mtYeofLFZpTas2S9zY+jIeuLJMNvudIgF52nr19q40HOwH5RrhWIPuj9puybzSJiRrVg==",
6 | "_location": "/follow-redirects",
7 | "_phantomChildren": {},
8 | "_requested": {
9 | "type": "range",
10 | "registry": true,
11 | "raw": "follow-redirects@^1.10.0",
12 | "name": "follow-redirects",
13 | "escapedName": "follow-redirects",
14 | "rawSpec": "^1.10.0",
15 | "saveSpec": null,
16 | "fetchSpec": "^1.10.0"
17 | },
18 | "_requiredBy": [
19 | "/axios"
20 | ],
21 | "_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.0.tgz",
22 | "_shasum": "f5d260f95c5f8c105894491feee5dc8993b402fe",
23 | "_spec": "follow-redirects@^1.10.0",
24 | "_where": "/home/andy/GitHubCloned/Requests-API-in-js/node_modules/axios",
25 | "author": {
26 | "name": "Ruben Verborgh",
27 | "email": "ruben@verborgh.org",
28 | "url": "https://ruben.verborgh.org/"
29 | },
30 | "bugs": {
31 | "url": "https://github.com/follow-redirects/follow-redirects/issues"
32 | },
33 | "bundleDependencies": false,
34 | "contributors": [
35 | {
36 | "name": "Olivier Lalonde",
37 | "email": "olalonde@gmail.com",
38 | "url": "http://www.syskall.com"
39 | },
40 | {
41 | "name": "James Talmage",
42 | "email": "james@talmage.io"
43 | }
44 | ],
45 | "deprecated": false,
46 | "description": "HTTP and HTTPS modules that follow redirects.",
47 | "devDependencies": {
48 | "concat-stream": "^2.0.0",
49 | "eslint": "^5.16.0",
50 | "express": "^4.16.4",
51 | "lolex": "^3.1.0",
52 | "mocha": "^6.0.2",
53 | "nyc": "^14.1.1"
54 | },
55 | "engines": {
56 | "node": ">=4.0"
57 | },
58 | "files": [
59 | "*.js"
60 | ],
61 | "funding": [
62 | {
63 | "type": "individual",
64 | "url": "https://github.com/sponsors/RubenVerborgh"
65 | }
66 | ],
67 | "homepage": "https://github.com/follow-redirects/follow-redirects",
68 | "keywords": [
69 | "http",
70 | "https",
71 | "url",
72 | "redirect",
73 | "client",
74 | "location",
75 | "utility"
76 | ],
77 | "license": "MIT",
78 | "main": "index.js",
79 | "name": "follow-redirects",
80 | "peerDependenciesMeta": {
81 | "debug": {
82 | "optional": true
83 | }
84 | },
85 | "repository": {
86 | "type": "git",
87 | "url": "git+ssh://git@github.com/follow-redirects/follow-redirects.git"
88 | },
89 | "scripts": {
90 | "lint": "eslint *.js test",
91 | "mocha": "nyc mocha",
92 | "test": "npm run lint && npm run mocha"
93 | },
94 | "version": "1.14.0"
95 | }
96 |
--------------------------------------------------------------------------------
/node_modules/readline-sync/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 anseki
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/node_modules/readline-sync/README-Deprecated.md:
--------------------------------------------------------------------------------
1 | # readlineSync
2 |
3 | ## Deprecated Methods and Options
4 |
5 | The readlineSync current version is fully compatible with older version.
6 | The following methods and options are deprecated.
7 |
8 | ### `setPrint` method
9 |
10 | Use the [`print`](README.md#basic_options-print) option.
11 | For the [Default Options](README.md#basic_options), use:
12 |
13 | ```js
14 | readlineSync.setDefaultOptions({print: value});
15 | ```
16 |
17 | instead of:
18 |
19 | ```js
20 | readlineSync.setPrint(value);
21 | ```
22 |
23 | ### `setPrompt` method
24 |
25 | Use the [`prompt`](README.md#basic_options-prompt) option.
26 | For the [Default Options](README.md#basic_options), use:
27 |
28 | ```js
29 | readlineSync.setDefaultOptions({prompt: value});
30 | ```
31 |
32 | instead of:
33 |
34 | ```js
35 | readlineSync.setPrompt(value);
36 | ```
37 |
38 | ### `setEncoding` method
39 |
40 | Use the [`encoding`](README.md#basic_options-encoding) option.
41 | For the [Default Options](README.md#basic_options), use:
42 |
43 | ```js
44 | readlineSync.setDefaultOptions({encoding: value});
45 | ```
46 |
47 | instead of:
48 |
49 | ```js
50 | readlineSync.setEncoding(value);
51 | ```
52 |
53 | ### `setMask` method
54 |
55 | Use the [`mask`](README.md#basic_options-mask) option.
56 | For the [Default Options](README.md#basic_options), use:
57 |
58 | ```js
59 | readlineSync.setDefaultOptions({mask: value});
60 | ```
61 |
62 | instead of:
63 |
64 | ```js
65 | readlineSync.setMask(value);
66 | ```
67 |
68 | ### `setBufferSize` method
69 |
70 | Use the [`bufferSize`](README.md#basic_options-buffersize) option.
71 | For the [Default Options](README.md#basic_options), use:
72 |
73 | ```js
74 | readlineSync.setDefaultOptions({bufferSize: value});
75 | ```
76 |
77 | instead of:
78 |
79 | ```js
80 | readlineSync.setBufferSize(value);
81 | ```
82 |
83 | ### `noEchoBack` option
84 |
85 | Use [`hideEchoBack`](README.md#basic_options-hideechoback) option instead of it.
86 |
87 | ### `noTrim` option
88 |
89 | Use [`keepWhitespace`](README.md#basic_options-keepwhitespace) option instead of it.
90 |
--------------------------------------------------------------------------------
/node_modules/readline-sync/lib/encrypt.js:
--------------------------------------------------------------------------------
1 | /*
2 | * readlineSync
3 | * https://github.com/anseki/readline-sync
4 | *
5 | * Copyright (c) 2019 anseki
6 | * Licensed under the MIT license.
7 | */
8 |
9 | var cipher = require('crypto').createCipher(
10 | process.argv[2] /*algorithm*/, process.argv[3] /*password*/),
11 | stdin = process.stdin,
12 | stdout = process.stdout,
13 | crypted = '';
14 |
15 | stdin.resume();
16 | stdin.setEncoding('utf8');
17 | stdin.on('data', function(d) {
18 | crypted += cipher.update(d, 'utf8', 'hex');
19 | });
20 | stdin.on('end', function() {
21 | stdout.write(crypted + cipher.final('hex'), 'binary', function() {
22 | process.exit(0);
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/node_modules/readline-sync/lib/read.cs.js:
--------------------------------------------------------------------------------
1 | /* jshint wsh:true */
2 |
3 | /*
4 | * readlineSync
5 | * https://github.com/anseki/readline-sync
6 | *
7 | * Copyright (c) 2019 anseki
8 | * Licensed under the MIT license.
9 | */
10 |
11 | var
12 | FSO_ForReading = 1, FSO_ForWriting = 2,
13 | PS_MSG = 'Microsoft Windows PowerShell is required.' +
14 | ' https://technet.microsoft.com/en-us/library/hh847837.aspx',
15 |
16 | input = '', fso, tty,
17 | options = (function(conf) {
18 | var options = {}, arg, args =// Array.prototype.slice.call(WScript.Arguments),
19 | (function() {
20 | var args = [], i, iLen;
21 | for (i = 0, iLen = WScript.Arguments.length; i < iLen; i++)
22 | { args.push(WScript.Arguments(i)); }
23 | return args;
24 | })(),
25 | confLc = {}, key;
26 |
27 | function decodeArg(arg) {
28 | return arg.replace(/#(\d+);/g, function(str, charCode) {
29 | return String.fromCharCode(+charCode);
30 | });
31 | }
32 |
33 | for (key in conf) {
34 | if (conf.hasOwnProperty(key))
35 | { confLc[key.toLowerCase()] = {key: key, type: conf[key]}; }
36 | }
37 |
38 | while (typeof(arg = args.shift()) === 'string') {
39 | if (!(arg = (arg.match(/^\-+(.+)$/) || [])[1])) { continue; }
40 | arg = arg.toLowerCase();
41 | if (confLc[arg]) {
42 | options[confLc[arg].key] =
43 | confLc[arg].type === 'boolean' ? true :
44 | confLc[arg].type === 'string' ? args.shift() : null;
45 | }
46 | }
47 | for (key in conf) {
48 | if (conf.hasOwnProperty(key) && conf[key] === 'string') {
49 | if (typeof options[key] !== 'string') { options[key] = ''; }
50 | else { options[key] = decodeArg(options[key]); }
51 | }
52 | }
53 | return options;
54 | })({
55 | display: 'string',
56 | displayOnly: 'boolean',
57 | keyIn: 'boolean',
58 | hideEchoBack: 'boolean',
59 | mask: 'string'
60 | });
61 |
62 | if (!options.hideEchoBack && !options.keyIn) {
63 | if (options.display) { writeTTY(options.display); }
64 | if (!options.displayOnly) { input = readByFSO(); }
65 | } else if (options.hideEchoBack && !options.keyIn && !options.mask) {
66 | if (options.display) { writeTTY(options.display); }
67 | if (!options.displayOnly) { input = readByPW(); }
68 | } else {
69 | WScript.StdErr.WriteLine(PS_MSG);
70 | WScript.Quit(1);
71 | }
72 |
73 | WScript.StdOut.Write('\'' + input + '\'');
74 |
75 | WScript.Quit();
76 |
77 | function writeTTY(text) {
78 | try {
79 | tty = tty || getFso().OpenTextFile('CONOUT$', FSO_ForWriting, true);
80 | tty.Write(text);
81 | } catch (e) {
82 | WScript.StdErr.WriteLine('TTY Write Error: ' + e.number +
83 | '\n' + e.description + '\n' + PS_MSG);
84 | WScript.Quit(e.number || 1);
85 | }
86 | }
87 |
88 | function readByFSO() {
89 | var text;
90 | try {
91 | text = getFso().OpenTextFile('CONIN$', FSO_ForReading).ReadLine();
92 | } catch (e) {
93 | WScript.StdErr.WriteLine('TTY Read Error: ' + e.number +
94 | '\n' + e.description + '\n' + PS_MSG);
95 | WScript.Quit(e.number || 1);
96 | }
97 | return text;
98 | }
99 |
100 | // TTY must be STDIN that is not redirected and not piped.
101 | function readByPW() {
102 | var text;
103 | try {
104 | text = WScript.CreateObject('ScriptPW.Password').GetPassword()
105 | // Bug? Illegal data may be returned when user types before initializing.
106 | .replace(/[\u4000-\u40FF]/g, function(chr) {
107 | var charCode = chr.charCodeAt(0);
108 | return charCode >= 0x4020 && charCode <= 0x407F ?
109 | String.fromCharCode(charCode - 0x4000) : '';
110 | });
111 | } catch (e) {
112 | WScript.StdErr.WriteLine('ScriptPW.Password Error: ' + e.number +
113 | '\n' + e.description + '\n' + PS_MSG);
114 | WScript.Quit(e.number || 1);
115 | }
116 | writeTTY('\n');
117 | return text;
118 | }
119 |
120 | function getFso() {
121 | if (!fso) { fso = new ActiveXObject('Scripting.FileSystemObject'); }
122 | return fso;
123 | }
124 |
--------------------------------------------------------------------------------
/node_modules/readline-sync/lib/read.ps1:
--------------------------------------------------------------------------------
1 | # readlineSync
2 | # https://github.com/anseki/readline-sync
3 | #
4 | # Copyright (c) 2019 anseki
5 | # Licensed under the MIT license.
6 |
7 | Param(
8 | [string] $display,
9 | [switch] $displayOnly,
10 | [switch] $keyIn,
11 | [switch] $hideEchoBack,
12 | [string] $mask,
13 | [string] $limit,
14 | [switch] $caseSensitive
15 | )
16 |
17 | $ErrorActionPreference = 'Stop' # for cmdlet
18 | trap {
19 | # `throw $_` and `Write-Error $_` return exit-code 0
20 | $Host.UI.WriteErrorLine($_)
21 | exit 1
22 | }
23 |
24 | function decodeArg ($arg) {
25 | [Regex]::Replace($arg, '#(\d+);', { [char][int] $args[0].Groups[1].Value })
26 | }
27 |
28 | $options = @{}
29 | foreach ($arg in @('display', 'displayOnly', 'keyIn', 'hideEchoBack', 'mask', 'limit', 'caseSensitive')) {
30 | $options.Add($arg, (Get-Variable $arg -ValueOnly))
31 | }
32 | $argList = New-Object string[] $options.Keys.Count
33 | $options.Keys.CopyTo($argList, 0)
34 | foreach ($arg in $argList) {
35 | if ($options[$arg] -is [string] -and $options[$arg])
36 | { $options[$arg] = decodeArg $options[$arg] }
37 | }
38 |
39 | [string] $inputTTY = ''
40 | [bool] $silent = -not $options.display -and
41 | $options.keyIn -and $options.hideEchoBack -and -not $options.mask
42 | [bool] $isCooked = -not $options.hideEchoBack -and -not $options.keyIn
43 |
44 | # Instant method that opens TTY without CreateFile via P/Invoke in .NET Framework
45 | # **NOTE** Don't include special characters of DOS in $command when $getRes is True.
46 | # [string] $cmdPath = $Env:ComSpec
47 | # [string] $psPath = 'powershell.exe'
48 | function execWithTTY ($command, $getRes = $False, $throwError = $False) {
49 | if ($getRes) {
50 | $res = (cmd.exe /C "CON powershell.exe -Command -"
58 | if ($LastExitCode -ne 0) {
59 | if ($throwError) { throw $LastExitCode }
60 | else { exit $LastExitCode }
61 | }
62 | }
63 | }
64 |
65 | function writeTTY ($text) {
66 | execWithTTY ('Write-Host (''' +
67 | (($text -replace '''', '''''') -replace '[\r\n]', '''+"`n"+''') + ''') -NoNewline')
68 | }
69 |
70 | if ($options.display) {
71 | writeTTY $options.display
72 | }
73 | if ($options.displayOnly) { return "''" }
74 |
75 | if (-not $options.keyIn -and $options.hideEchoBack -and $options.mask -eq '*') {
76 | # It fails when it's not ready.
77 | try {
78 | $inputTTY = execWithTTY ('$text = Read-Host -AsSecureString;' +
79 | '$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($text);' +
80 | '[Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)') $True $True
81 | return '''' + $inputTTY + ''''
82 | } catch {} # ignore
83 | }
84 |
85 | if ($options.keyIn) { $reqSize = 1 }
86 |
87 | if ($options.keyIn -and $options.limit) {
88 | $limitPtn = '[^' + $options.limit + ']'
89 | }
90 |
91 | while ($True) {
92 | if (-not $isCooked) {
93 | $chunk = [char][int] (execWithTTY '[int] [Console]::ReadKey($True).KeyChar' $True)
94 | } else {
95 | $chunk = execWithTTY 'Read-Host' $True
96 | $chunk += "`n"
97 | }
98 |
99 | if ($chunk -and $chunk -match '^(.*?)[\r\n]') {
100 | $chunk = $Matches[1]
101 | $atEol = $True
102 | } else { $atEol = $False }
103 |
104 | # other ctrl-chars
105 | if ($chunk) { $chunk = $chunk -replace '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]', '' }
106 | if ($chunk -and $limitPtn) {
107 | if ($options.caseSensitive) { $chunk = $chunk -creplace $limitPtn, '' }
108 | else { $chunk = $chunk -ireplace $limitPtn, '' }
109 | }
110 |
111 | if ($chunk) {
112 | if (-not $isCooked) {
113 | if (-not $options.hideEchoBack) {
114 | writeTTY $chunk
115 | } elseif ($options.mask) {
116 | writeTTY ($options.mask * $chunk.Length)
117 | }
118 | }
119 | $inputTTY += $chunk
120 | }
121 |
122 | if ((-not $options.keyIn -and $atEol) -or
123 | ($options.keyIn -and $inputTTY.Length -ge $reqSize)) { break }
124 | }
125 |
126 | if (-not $isCooked -and -not $silent) { execWithTTY 'Write-Host ''''' } # new line
127 |
128 | return "'$inputTTY'"
129 |
--------------------------------------------------------------------------------
/node_modules/readline-sync/lib/read.sh:
--------------------------------------------------------------------------------
1 | # readlineSync
2 | # https://github.com/anseki/readline-sync
3 | #
4 | # Copyright (c) 2019 anseki
5 | # Licensed under the MIT license.
6 |
7 | # Use perl for compatibility of sed/awk of GNU / POSIX, BSD. (and tr)
8 | # Hide "\n" from shell by "\fNL"
9 |
10 | decode_arg() {
11 | printf '%s' "$(printf '%s' "$1" | perl -pe 's/#(\d+);/sprintf("%c", $1)/ge; s/[\r\n]/\fNL/g')"
12 | }
13 |
14 | # getopt(s)
15 | while [ $# -ge 1 ]; do
16 | arg="$(printf '%s' "$1" | grep -E '^-+[^-]+$' | tr '[A-Z]' '[a-z]' | tr -d '-')"
17 | case "$arg" in
18 | 'display') shift; options_display="$(decode_arg "$1")";;
19 | 'displayonly') options_displayOnly=true;;
20 | 'keyin') options_keyIn=true;;
21 | 'hideechoback') options_hideEchoBack=true;;
22 | 'mask') shift; options_mask="$(decode_arg "$1")";;
23 | 'limit') shift; options_limit="$(decode_arg "$1")";;
24 | 'casesensitive') options_caseSensitive=true;;
25 | esac
26 | shift
27 | done
28 |
29 | reset_tty() {
30 | if [ -n "$save_tty" ]; then
31 | stty --file=/dev/tty "$save_tty" 2>/dev/null || \
32 | stty -F /dev/tty "$save_tty" 2>/dev/null || \
33 | stty -f /dev/tty "$save_tty" || exit $?
34 | fi
35 | }
36 | trap 'reset_tty' EXIT
37 | save_tty="$(stty --file=/dev/tty -g 2>/dev/null || stty -F /dev/tty -g 2>/dev/null || stty -f /dev/tty -g || exit $?)"
38 |
39 | [ -z "$options_display" ] && [ "$options_keyIn" = true ] && \
40 | [ "$options_hideEchoBack" = true ] && [ -z "$options_mask" ] && silent=true
41 | [ "$options_hideEchoBack" != true ] && [ "$options_keyIn" != true ] && is_cooked=true
42 |
43 | write_tty() {
44 | # if [ "$2" = true ]; then
45 | # printf '%b' "$1" >/dev/tty
46 | # else
47 | # printf '%s' "$1" >/dev/tty
48 | # fi
49 | printf '%s' "$1" | perl -pe 's/\fNL/\r\n/g' >/dev/tty
50 | }
51 |
52 | replace_allchars() { (
53 | text=''
54 | for i in $(seq 1 ${#1})
55 | do
56 | text="$text$2"
57 | done
58 | printf '%s' "$text"
59 | ) }
60 |
61 | if [ -n "$options_display" ]; then
62 | write_tty "$options_display"
63 | fi
64 | if [ "$options_displayOnly" = true ]; then
65 | printf "'%s'" ''
66 | exit 0
67 | fi
68 |
69 | if [ "$is_cooked" = true ]; then
70 | stty --file=/dev/tty cooked 2>/dev/null || \
71 | stty -F /dev/tty cooked 2>/dev/null || \
72 | stty -f /dev/tty cooked || exit $?
73 | else
74 | stty --file=/dev/tty raw -echo 2>/dev/null || \
75 | stty -F /dev/tty raw -echo 2>/dev/null || \
76 | stty -f /dev/tty raw -echo || exit $?
77 | fi
78 |
79 | [ "$options_keyIn" = true ] && req_size=1
80 |
81 | if [ "$options_keyIn" = true ] && [ -n "$options_limit" ]; then
82 | if [ "$options_caseSensitive" = true ]; then
83 | limit_ptn="$options_limit"
84 | else
85 | # Safe list
86 | # limit_ptn="$(printf '%s' "$options_limit" | sed 's/\([a-z]\)/\L\1\U\1/ig')"
87 | limit_ptn="$(printf '%s' "$options_limit" | perl -pe 's/([a-z])/lc($1) . uc($1)/ige')"
88 | fi
89 | fi
90 |
91 | while :
92 | do
93 | if [ "$is_cooked" != true ]; then
94 | # chunk="$(dd if=/dev/tty bs=1 count=1 2>/dev/null)"
95 | chunk="$(dd if=/dev/tty bs=1 count=1 2>/dev/null | perl -pe 's/[\r\n]/\fNL/g')"
96 | else
97 | IFS= read -r chunk = 0.8.0"
38 | },
39 | "files": [
40 | "lib/*.@(js|ps1|sh)",
41 | "README-Deprecated.md"
42 | ],
43 | "homepage": "https://github.com/anseki/readline-sync",
44 | "keywords": [
45 | "readline",
46 | "synchronous",
47 | "interactive",
48 | "prompt",
49 | "question",
50 | "password",
51 | "cli",
52 | "tty",
53 | "command",
54 | "repl",
55 | "keyboard",
56 | "wait",
57 | "block"
58 | ],
59 | "license": "MIT",
60 | "main": "./lib/readline-sync.js",
61 | "name": "readline-sync",
62 | "repository": {
63 | "type": "git",
64 | "url": "git://github.com/anseki/readline-sync.git"
65 | },
66 | "title": "readlineSync",
67 | "version": "1.4.10"
68 | }
69 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "axios": {
6 | "version": "0.21.1",
7 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
8 | "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
9 | "requires": {
10 | "follow-redirects": "^1.10.0"
11 | }
12 | },
13 | "follow-redirects": {
14 | "version": "1.14.0",
15 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.0.tgz",
16 | "integrity": "sha512-0vRwd7RKQBTt+mgu87mtYeofLFZpTas2S9zY+jIeuLJMNvudIgF52nr19q40HOwH5RrhWIPuj9puybzSJiRrVg=="
17 | },
18 | "readline-sync": {
19 | "version": "1.4.10",
20 | "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz",
21 | "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw=="
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/requests_api.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | var axios = require("axios");
4 | var fs = require("fs");
5 | var readline = require("readline-sync");
6 |
7 | fs.exists(__dirname + "/courses.json",(exists)=>{
8 | if(!exists){
9 | axios.get("http://saral.navgurukul.org/api/courses")
10 | .then(function (response){
11 | var mydata = response.data
12 | // console.log(mydata)
13 | var data1 = JSON.stringify(mydata)
14 | var data2 = fs.writeFileSync("courses.json",data1);
15 | // console.log(data2)
16 | })
17 | .catch(function(error){
18 | console.log(error.response.status);
19 | })
20 | }else{
21 | var data2 = fs.readFileSync('courses.json')
22 | var coursesdata = JSON.parse(data2)
23 | // console.log(coursesdata.availableCourses);
24 | var course = coursesdata.availableCourses
25 |
26 | var list_of_id = [];
27 | var number = 0;
28 | for (i of course){
29 | console.log(number,i.name);
30 | // console.log(i.id);
31 | list_of_id.push(i.id);
32 | number+=1;
33 |
34 | }
35 | // console.log(list_of_id);
36 | }
37 | var user = readline.question("\n\nChoose your course id:-");
38 | for (var i in list_of_id){
39 | // console.log(i)
40 | if(i == user){
41 | // console.log(list_of_id[i]);
42 | var id = (list_of_id[i]);
43 | axios.get("http://saral.navgurukul.org/api/courses/"+id+"/exercises")
44 | .then (function (response){
45 | var datalink = response.data
46 | // console.log(datalink.data);
47 | var mydatalink = datalink.data;
48 | var number1 = 0;
49 | slug_list = [];
50 | nubmer_list = [];
51 | for ( j of mydatalink){
52 | // console.log(j.slug)
53 | var slug = (j.slug)
54 | console.log(number1,j.name);
55 | ChildExercises = (number,j.childExercises);
56 | slug_list.push(slug);
57 | // console.log(slug_list);
58 | nubmer_list.push(number1);
59 | number2 = 0.1;
60 | for (k of ChildExercises){
61 | var n = number1+number2;
62 | console.log(' ',n,k.name);
63 | slug_list.push(k.slug);
64 | nubmer_list.push(n);
65 | number2 += 0.1;
66 | }
67 | number1+=1
68 |
69 | }
70 | console.log("\n------------------------sahi khel raha hai bhai tu----------------------\n")
71 |
72 | var user_5 = readline.question("input your course content number:-");
73 | for (l in nubmer_list){
74 | if(nubmer_list[l] == user_5){
75 | var slug = (slug_list[l]);
76 | axios.get("http://saral.navgurukul.org/api/courses/"+id+"/exercise/getBySlug?slug="+slug)
77 | .then (function (response){
78 | var content = response.data;
79 | console.log(content.content);
80 | });
81 | }
82 | }
83 |
84 | })
85 | }
86 |
87 | }
88 |
89 | });
90 |
91 |
92 |
--------------------------------------------------------------------------------