How to use authToken method in argos

Best JavaScript code snippet using argos

InterfaceAPI.js

Source:InterfaceAPI.js Github

copy

Full Screen

1/**2 * Created by Benson on 2017/3/31.3 */4const _API = '/';5//文章列表接口6export const ARTICLE = function (type,page,pageSize){7 const httpAPI = _API+'app/api/common/articles?type='+type+'&page='+page+'&pageSize='+pageSize;8 return httpAPI;9}10//文章详情11export const ARTICLEDETAILS = function (id){12 const httpAPI = _API+'app/api/common/article/'+id;13 return httpAPI;14}15//获取用户组(主管医生)16export const The_docGroup = function(authToken){17 const httpAPI = _API+'app/api/topThreeService/get/groupType';18 return {url:httpAPI,type:'GET',headers: {19 "authToken":authToken20 }};21}22//风险评估(列表+正文)23export const The_risk_assessment = function(customerid,page,pageSize,authToken){24 const httpAPI = _API+'app/api/account/riskreport/infos?customerid='+customerid+'&iscustomer=true&page='+page+'&pageSize='+pageSize;25 return {url:httpAPI,type:'GET',headers: {26 "authToken":authToken27 }};28}29//健康管理计划评估(列表+正文)30export const the_health_managements = function(customerid,page,pageSize,authToken){31 const httpAPI = _API+'app/api/account/getHealthManagements?customerId='+customerid+'&page='+page+'&pageSize='+pageSize;32 return {url:httpAPI,type:'GET',headers: {33 "authToken":authToken34 },};35}36//月、季度报告(列表) type=1 月度 =2季度37export const getAutomationReport = function(type,page,pageSize,authToken){38 const httpAPI = _API+'app/api/account/getAutomationReport?type='+type+'&page='+page+'&pageSize='+pageSize;39 return {url:httpAPI,type:'GET',headers: {40 "authToken":authToken41 },};42}43//月季详情44export const getAutomationReportDatil = function(end,start,authToken){45 const httpAPI = _API+'app/api/account/get/pic/sumReport?endDate='+end+'&startDate='+start;46 return {url:httpAPI,type:'GET',headers: {47 "authToken":authToken48 },};49}50//年度报告(列表)51export const majordignosereport = function(customerid,page,pageSize,authToken){52 const httpAPI = _API+'app/api/account/majordignosereport/infos?customerid='+customerid+'&page='+page+'&pageSize='+pageSize;53 return {url:httpAPI,type:'GET',headers: {54 "authToken":authToken55 },};56}57//年度报告(详情)58export const majordignosereportDatil = function(customerid,id,authToken){59 const httpAPI = _API+'app/api/doctor/health/info/dailyinfo/data/'+customerid+'?cusid='+customerid+'&repId='+id;60 return {url:httpAPI,type:'GET',headers: {61 "authToken":authToken62 }};63}64//下载报告65export const DownLoadRepot = function(id,authToken){66 const httpAPI = _API+'app/api/report/riskAssessment?id='+id;67 return {url:httpAPI,type:'GET',contentType:'application/octet-stream; charset=utf-8',headers: {68 "authToken":authToken69 }};70}71//用户数据查询(血压,血糖。。。)72export const UserData = function(dataType,endTime,startTime,page,pageSize,authToken){73 const httpAPI = _API+'app/api/account/health/check/infos?dataType='+dataType+'&endDate='+endTime+'&page='+page+'&pageSize='+pageSize+'&startDate='+startTime;74 return {url:httpAPI,type:'GET',headers: {75 "authToken":authToken76 },};77}78//用户数据图标查询(血压,血糖。。。)79export const UserDataImg = function(dataType,endTime,startTime,authToken){80 const httpAPI = _API+'app/api/account/health/report?endDate='+endTime+'&startDate='+startTime+'&type='+dataType;81 return {url:httpAPI,type:'GET',headers: {82 "authToken":authToken83 }};84}85//数据预览86export const UserHelDate = function (){87 const httpAPI = _API+'app/api/account/conversion/health/check/infos';88 return httpAPI;89}90//数据提交91export const UserHelDatePost = function (){92 const httpAPI = _API+'app/api/account/health/check/infos';93 return httpAPI;94}95//健管师提问列表所有96export const ASKMList = function(page,pageSize,authToken){97 const httpAPI = _API+'app/api/common/health/advices?page='+page+'&pageSize='+pageSize;98 return {url:httpAPI,type:'GET',headers: {99 "authToken":authToken100 }};101}102//健管师提问列表我的103export const ASKMListMy = function(page,pageSize,authToken){104 const httpAPI = _API+'app/api/account/health/advices?page='+page+'&pageSize='+pageSize;105 return {url:httpAPI,type:'GET',headers: {106 "authToken":authToken107 }};108}109//健管师提问详情110export const ASKMDatile = function(page,pageSize,id,authToken){111 const httpAPI = _API+'app/api/consult/health/advice/'+id+'/replies?page='+page+'&pageSize='+pageSize;112 return {url:httpAPI,type:'GET',headers: {113 "authToken":authToken114 }};115}116//健管师提问详情,用户回复117export const ASKMDatileUserInput = function(authToken){118 const httpAPI = _API+'app/api/consult/advice/reply';119 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {120 "authToken":authToken121 },error(rs){alert(rs.responseJSON.message)}};122}123//健管师提交问题124export const ASKMPost = function(authToken){125 const httpAPI = _API+'app/api/consult/advice';126 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {127 "authToken":authToken128 }};129}130//医生提问列表131export const ASKDOCList = function(page,pageSize,authToken){132 const httpAPI = _API+'app/api/account/health/consults?page='+page+'&pageSize='+pageSize;133 return {url:httpAPI,type:'GET',headers: {134 "authToken":authToken135 }};136}137//医生提交问题138export const ASKDOCPost = function(authToken){139 const httpAPI = _API+'app/api/account/health/consult';140 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {141 "authToken":authToken142 },error(a,b,c){alert(a.responseJSON.message)}};143}144//医生提问详情145export const ASKDOCDatile = function(id,authToken){146 const httpAPI = _API+'app/api/account/health/consult/'+id147 return {url:httpAPI,type:'GET',headers: {148 "authToken":authToken149 }};150}151//评价医生咨询152export const ASKDOCcommentPost = function(id,authToken){153 const httpAPI = _API+'app/api/account/health/consult/'+id+'/comment';154 return {url:httpAPI,contentType : 'application/json',headers: {155 "authToken":authToken156 }};157}158//问医生列表中的团队159export const ASKDOCGetGroup = function(authToken){160 const httpAPI = _API+'app/api/account/health/groups';161 return {url:httpAPI,type:'GET',headers: {162 "authToken":authToken163 }};164}165//剩余询问次数166export const ASKTIME = function(authToken){167 const httpAPI = _API+'app/api/servicePackage/getCustomerServiceDetail';168 return {url:httpAPI,type:'GET',headers: {169 "authToken":authToken170 }};171}172//健康团队列表173export const HealthTeamList = function(page,pageSize,authToken){174 const httpAPI = _API+'app/api/account/query/health/groups?page='+page+'&pageSize='+pageSize;175 return {url:httpAPI,type:'GET',headers: {176 "authToken":authToken177 }};178}179//健康团队详情-A 团队180export const HealthTeamGroup = function(id){181 const httpAPI = _API+'app/api/common/health/group/'+id;182 return {url:httpAPI,type:'GET'};183}184//健康团队详情-B 医生185export const HealthTeamDoc = function(id){186 const httpAPI = _API+'app/api/common/health/group/'+id+'/doctors';187 return {url:httpAPI,type:'GET'};188}189//查询医生详情190export const DocDatile = function(id){191 const httpAPI = _API+'app/api/common/doctor/'+id;192 return {url:httpAPI,type:'GET'};193}194//查询医生评价195export const DocDatileComments = function(id){196 const httpAPI = _API+'app/api/common/doctor/'+id+'/comments';197 return {url:httpAPI,type:'GET'};198}199//获取省份200export const GetProvinces = function(){201 const httpAPI = _API+'app/api/common/provinces';202 return {url:httpAPI,type:'GET'};203}204//获取城市205export const GetCity = function(proID){206 const httpAPI = _API+'app/api/common/cities/province/'+proID;207 return {url:httpAPI,type:'GET'};208}209//个人中心 个人信息210export const GETUserData = function(authToken){211 const httpAPI = _API+'app/api/account/get/customer/data';212 return {url:httpAPI,type:'GET',headers: {213 "authToken":authToken214 }};215}216//个人中心 提交个人信息217export const POSTUserData = function(authToken){218 const httpAPI = _API+'app/api/account/update/customer/data';219 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {220 "authToken":authToken221 }};222}223//个人中心 基本数据224export const GETUserBaseData = function(authToken){225 const httpAPI = _API+'app/api/account/get/customer/basic';226 return {url:httpAPI,type:'GET',headers: {227 "authToken":authToken228 }};229}230//个人中心 提交基本数据231export const POSTUserBaseData = function(authToken){232 const httpAPI = _API+'app/api/account/update/customer/basic';233 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {234 "authToken":authToken235 }};236}237//个人中心 既往病史238export const GETUserHistory = function(authToken){239 const httpAPI = _API+'app/api/account/get/customer/history';240 return {url:httpAPI,type:'GET',headers: {241 "authToken":authToken242 }};243}244//个人中心 提交既往病史245export const POSTUserHistory = function(authToken){246 const httpAPI = _API+'app/api/account/update/customer/history';247 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {248 "authToken":authToken249 }};250}251//个人中心 删除既往病史记录252export const DelUserHistory = function(id,authToken){253 const httpAPI = _API+'app/api/common/delete/info?id='+id+'&type=1';254 return {url:httpAPI,type:'GET',contentType : 'application/json',headers: {255 "authToken":authToken256 }};257}258//个人中心 药物259export const GETUserSituation = function(authToken){260 const httpAPI = _API+'app/api/account/get/customer/drug';261 return {url:httpAPI,type:'GET',headers: {262 "authToken":authToken263 }};264}265//个人中心 药物删除266export const DelUserSituation = function(id,authToken){267 const httpAPI = _API+'app/api/common/delete/info?id='+id+'&type=0';268 return {url:httpAPI,type:'GET',headers: {269 "authToken":authToken270 }};271}272//个人中心 药物列表 1药物名 2化学名273export const Getmedicine = function(type){274 const httpAPI = _API+'app/api/common/Medicine/names?type='+type;275 return {url:httpAPI,type:'GET'};276}277//个人中心 药物列表根据名称获取278export const GetmedicineByName = function(name){279 const httpAPI = _API+'app/api/common/Medicine/names?type=1&chemicalName='+name;280 return {url:httpAPI,type:'GET'};281}282//个人中心 药物化学名根据名称获取283export const GetmedicineHuaXueByName= function(name){284 const httpAPI = _API+'app/api/common/Medicine/names?type=2&name='+name;285 return {url:httpAPI,type:'GET'};286}287//个人中心 药物提交288export const PostUserSituation = function(authToken){289 const httpAPI = _API+'app/api/account/update/customer/drug';290 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {291 "authToken":authToken292 }};293}294//个人中心 医疗事件295export const GETUserEvent = function(authToken){296 const httpAPI = _API+'app/api/account/get/customer/event';297 return {url:httpAPI,type:'GET',headers: {298 "authToken":authToken299 }};300}301//个人中心 医疗事件修改302export const PostUserEvent = function(authToken){303 const httpAPI = _API+'app/api/account/update/customer/event';304 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {305 "authToken":authToken306 }};307}308//修改密码309export const changePWD = function(){310 const httpAPI = _API+'app/api/account/setting/password';311 return httpAPI312}313//个人中心 消息列表 type=1消息 =2公告314export const Getmessages = function(page,pageSize,type,authToken){315 const httpAPI = _API+'app/api/account/messages?isGuardian=false&page='+page+'&pageSize='+pageSize+'&type='+type;316 return {url:httpAPI,type:'GET',headers: {317 "authToken":authToken318 }};319}320export const GetmessagesByID = function(id,authToken,type){321 const httpAPI = _API+'app/api/account/message/'+id+'/type/'+type;322 return {url:httpAPI,type:'GET',headers: {323 "authToken":authToken324 }};325}326// 标记已读327export const redmessages = function(authToken){328 const httpAPI = _API+'app/api/account/message/operate';329 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {330 "authToken":authToken331 }};332}333export const LoginAPI = function(){334 const httpAPI = _API+'app/api/account/login';335 return httpAPI;336}337//未使用338export const LoginAPIYZM = function(){339 const httpAPI = _API+'captcha';340 return {url:httpAPI,type:'GET'};341}342export const LoginOutAPI = function(authToken){343 const httpAPI = _API+'app/api/account/logout';344 return {url:httpAPI,type:'POST',headers: {345 "authToken":authToken346 }};347}348export const fogetPWD = function(name,idNum){349 const httpAPI = _API+'app/api/common/getCustomerQuestion?idCardNumber='+idNum+'&username='+name;350 return {url:httpAPI,type:'GET'};351}352export const getCustomerSafeAnswer = function(id,safeAnswer){353 const httpAPI = _API+'app/api/common/getCustomerSafeAnswer?id='+id+'&safeAnswer='+safeAnswer;354 return {url:httpAPI,type:'GET'};355}356export const getCustomerPassword = function(id,password){357 const httpAPI = _API+'app/api/common/getCustomerPassword?id='+id+'&password='+password;358 return {url:httpAPI,type:'GET'};359}360//未使用361export const protocol = function(){362 const httpAPI = _API+'app/api/common/protocol';363 return {url:httpAPI,type:'GET'};364}365//获取未读消息 (type 2通知、互动总数 1日程 3问医生 8问健康管理师) head使用366export const getMessagesNoRead = (authToken,type)=>{367 const httpAPI = _API+'app/api/account/statistics/'+type;368 return {url:httpAPI,type:'GET',headers: {369 "authToken":authToken370 },error(){ sessionStorage.clear('userData');localStorage.clear();}};371}372//获取未读消息(type 1消息 2公告)373export const getMesNoRead = (authToken,type)=>{374 const httpAPI = _API+'app/api/account/message/new/count?type='+type;375 return {url:httpAPI,type:'GET',headers: {376 "authToken":authToken377 }};378}379//获取事件380export const GETDateEvent = (authToken,endDate,startDate)=>{381 const httpAPI = _API+'app/api/schedule/month?endDate='+endDate+'&startDate='+startDate;382 return {url:httpAPI,type:'GET',headers: {383 "authToken":authToken384 }};385}386//获取事件详情387export const GETDateEventDatile = (authToken,Date)=>{388 const httpAPI = _API+'app/api/schedule/day?date='+Date;389 return {url:httpAPI,type:'GET',headers: {390 "authToken":authToken391 }};392}393//修改日程394export const EditDateEvent = (authToken)=>{395 const httpAPI = _API+'app/api/schedule/edit';396 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {397 "authToken":authToken398 }};399}400//新建日程401export const NewDateEvent = (authToken)=>{402 const httpAPI = _API+'app/api/account/schedule';403 return {url:httpAPI,type:'POST',contentType : 'application/json',headers: {404 "authToken":authToken405 }};406}407//删除日程时间408export const DelDateEvent = (authToken,id)=>{409 const httpAPI = _API+'app/api/schedule/'+id;410 return {url:httpAPI,type:'DELETE',headers: {411 "authToken":authToken412 }};413}414//用户身份判断 (三甲,脑卒中)415export const UserGroupType = (authToken)=>{416 const httpAPI = _API+'app/api/topThreeService/get/groupType';417 return {url:httpAPI,type:'GET',headers: {418 "authToken":authToken419 }};420}421//三甲用户个人方案列表422export const UserTopThreeList = (userID,page,pageSize,authToken)=>{423 const httpAPI = _API+'app/api/account/getTopThreeHealthManagemenList?customerId='+userID+'&page='+page+'&pageSize='+pageSize;424 return {url:httpAPI,type:'GET',headers: {425 "authToken":authToken426 }};427}428//三甲用户个人方案详情429export const UserTopThreeDatile = (ID,authToken)=>{430 const httpAPI = _API+'app/api/doctor/getTopThreeHealthManagement/'+ID;431 return {url:httpAPI,type:'GET',headers: {432 "authToken":authToken433 }};434}435//三甲用户随访列表436export const UserTopThreeFUList = (page,authToken)=>{437 const httpAPI = _API+'app/api/topThreeService/get/topThreeServices?page='+page;438 return {url:httpAPI,type:'GET',headers: {439 "authToken":authToken440 }};441}442//获取我的服务列表443export const GetService = (type,authToken)=>{444 const httpAPI = _API+'app/api/account/getMyService/'+type;445 return {url:httpAPI,type:'GET',async:false,headers: {446 "authToken":authToken447 }};448}449//卒中随访列表450export const CerebralSList = (customerId,page,pageSize,authToken)=>{451 const httpAPI = _API+'app/api/strokeFollowUp/getStrokes?customerId='+customerId+"&page="+page+'&pageSize='+pageSize;452 return {url:httpAPI,type:'GET',async:false,headers: {453 "authToken":authToken454 }};455}456//卒中随访详情457export const CerebralSDatile = (strokeFollowUpId,authToken)=>{458 const httpAPI = _API+'app/api/strokeFollowUp/getRecords?strokeFollowUpId='+strokeFollowUpId;459 return {url:httpAPI,type:'GET',async:false,headers: {460 "authToken":authToken461 }};462}463//标记报告已读464export const sendRead = (type,id,authToken)=>{465 const httpAPI = _API+'app/api/account/update/'+type+'/report/'+id;466 return {url:httpAPI,type:'post',async:false,headers: {467 "authToken":authToken468 }};469}470//用户注册-检测用户名是否重复471export const registerCheckUserName = (userName)=>{472 const httpAPI = _API+'app/api/common/check/name/used?type=1&name='+userName;473 return {url:httpAPI,type:'get',async:false};474}475//用户注册-检测身份证是否重复476export const registerCheckregisterCheckUserName = (idCardNumber)=>{477 const httpAPI = _API+'app/api/common/check/idcard/used?idCardNumber='+idCardNumber;478 return {url:httpAPI,type:'get',async:true};479}480//用户注册-城市机构查询481export const registerCheckreGroup = (city,pr,page)=>{482 const httpAPI = _API+'app/api/common/health/findgroups?cityId='+city+'&page='+page+'&provinceId='+pr;483 return {url:httpAPI,type:'get',async:false};484}485//用户注册-提交信息486export const register= ()=>{487 const httpAPI = _API+'app/api/account/register';488 return {url:httpAPI,type:'post',contentType:'application/json'};489}490//问医生,补充资料491export const buchongtijiao= (id,authToken)=>{492 const httpAPI = _API+'app/api/account/health/consult/'+id;493 return {url:httpAPI,type:'post',contentType:'application/json',headers: {494 "authToken":authToken495 }};496}497//nmmp498export const chakannmmp= (id,authToken)=>{499 const httpAPI = _API+'app/api/account/health/check/info/'+id;500 return {url:httpAPI,type:'get',contentType:'application/json',headers: {501 "authToken":authToken502 }};503}504export const getyazm= ()=>{505 const httpAPI = _API+'captcha?' + Math.random();506 return httpAPI;507}508export const getOldLogin= ()=>{509 const httpAPI = 'http://'+window.location.host+'/index.html#/login';510 console.log(httpAPI);511 return httpAPI;512}513export const getOldCenter= ()=>{514 const httpAPI = _API+'index.html#/center';515 return httpAPI;516}517export const getDayPlan= (et, st, type)=>{518 const httpAPI = _API+'app/api/account/health/report?endDate='+et+"&startDate="+st+"&type="+type;519 return httpAPI;520}521export const getDownReport= (url, id)=>{522 const httpAPI = _API+'app/api/report/'+url+"?id="+id;523 return httpAPI;524}525export const getImg= (name)=>{526 const httpAPI = _API+'images/'+name+'.png';527 return httpAPI;528}529export const getDownCR= (name)=>{530 const httpAPI = _API+'index.html#/qr_code';531 return httpAPI;...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1const domain = "http://localhost:8080";2export const login = (credential, asHost) => {3 const loginUrl = `${domain}/authenticate/${asHost ? "host" : "guest"}`;4 return fetch(loginUrl, {5 method: "POST",6 headers: {7 "Content-Type": "application/json",8 },9 body: JSON.stringify(credential),10 }).then((response) => {11 if (response.status !== 200) {12 throw Error("Fail to log in");13 }14 return response.json();15 });16};17export const register = (credential, asHost) => {18 const registerUrl = `${domain}/register/${asHost ? "host" : "guest"}`;19 return fetch(registerUrl, {20 method: "POST",21 headers: {22 "Content-Type": "application/json",23 },24 body: JSON.stringify(credential),25 }).then((response) => {26 if (response.status !== 200) {27 throw Error("Fail to register");28 }29 });30};31export const getReservations = () => {32 const authToken = localStorage.getItem("authToken");33 const listReservationsUrl = `${domain}/reservations`;34 return fetch(listReservationsUrl, {35 headers: {36 Authorization: `Bearer ${authToken}`,37 },38 }).then((response) => {39 if (response.status !== 200) {40 throw Error("Fail to get reservation list");41 }42 return response.json();43 });44};45export const getStaysByHost = () => {46 const authToken = localStorage.getItem("authToken");47 const listStaysUrl = `${domain}/stays/`;48 return fetch(listStaysUrl, {49 headers: {50 Authorization: `Bearer ${authToken}`,51 },52 }).then((response) => {53 if (response.status !== 200) {54 throw Error("Fail to get stay list");55 }56 return response.json();57 });58};59export const searchStays = (query) => {60 const authToken = localStorage.getItem("authToken");61 const searchStaysUrl = new URL(`${domain}/search/`);62 searchStaysUrl.searchParams.append("guest_number", query.guest_number);63 searchStaysUrl.searchParams.append(64 "checkin_date",65 query.checkin_date.format("YYYY-MM-DD")66 );67 searchStaysUrl.searchParams.append(68 "checkout_date",69 query.checkout_date.format("YYYY-MM-DD")70 );71 searchStaysUrl.searchParams.append("lat", 37);72 searchStaysUrl.searchParams.append("lon", -122);73 return fetch(searchStaysUrl, {74 headers: {75 Authorization: `Bearer ${authToken}`,76 },77 }).then((response) => {78 if (response.status !== 200) {79 throw Error("Fail to search stays");80 }81 return response.json();82 });83};84export const deleteStay = (stayId) => {85 const authToken = localStorage.getItem("authToken");86 const deleteStayUrl = `${domain}/stays/${stayId}`;87 return fetch(deleteStayUrl, {88 method: "DELETE",89 headers: {90 Authorization: `Bearer ${authToken}`,91 },92 }).then((response) => {93 if (response.status !== 200) {94 throw Error("Fail to delete stay");95 }96 });97};98export const bookStay = (data) => {99 const authToken = localStorage.getItem("authToken");100 const bookStayUrl = `${domain}/reservations`;101 return fetch(bookStayUrl, {102 method: "POST",103 headers: {104 Authorization: `Bearer ${authToken}`,105 "Content-Type": "application/json",106 },107 body: JSON.stringify(data),108 }).then((response) => {109 if (response.status !== 200) {110 throw Error("Fail to book reservation");111 }112 });113};114export const cancelReservation = (reservationId) => {115 const authToken = localStorage.getItem("authToken");116 const cancelReservationUrl = `${domain}/reservations/${reservationId}`;117 return fetch(cancelReservationUrl, {118 method: "DELETE",119 headers: {120 Authorization: `Bearer ${authToken}`,121 },122 }).then((response) => {123 if (response.status !== 200) {124 throw Error("Fail to cancel reservation");125 }126 });127};128export const getReservationsByStay = (stayId) => {129 const authToken = localStorage.getItem("authToken");130 const getReservationByStayUrl = `${domain}/stays/reservations/${stayId}`;131 return fetch(getReservationByStayUrl, {132 headers: {133 Authorization: `Bearer ${authToken}`,134 },135 }).then((response) => {136 if (response.status !== 200) {137 throw Error("Fail to get reservations by stay");138 }139 return response.json();140 });141};142export const uploadStay = (data) => {143 const authToken = localStorage.getItem("authToken");144 const uploadStayUrl = `${domain}/stays`;145 return fetch(uploadStayUrl, {146 method: "POST",147 headers: {148 Authorization: `Bearer ${authToken}`,149 },150 body: data,151 }).then((response) => {152 if (response.status !== 200) {153 throw Error("Fail to upload stay");154 }155 });...

Full Screen

Full Screen

imgur-auth.service.ts

Source:imgur-auth.service.ts Github

copy

Full Screen

1import {Injectable} from '@angular/core';2import {AuthToken} from '../models/auth-token.model';3import {BehaviorSubject, Observable} from 'rxjs';4@Injectable({5 providedIn: 'root'6})7export class ImgurAuthService {8 static AUTH_TOKEN_STORAGE_KEY_NAME = 'imgur-auth-token';9 private _authTokenSubject: BehaviorSubject<AuthToken>;10 authToken$: Observable<AuthToken>;11 constructor() {12 const authToken = this._retrieveAuthDetails();13 this._authTokenSubject = new BehaviorSubject<AuthToken>(authToken);14 this.authToken$ = this._authTokenSubject.asObservable();15 }16 getCurrentAuthToken(): AuthToken {17 return this._authTokenSubject.getValue();18 }19 getAccessToken(): string {20 const authToken = this.getCurrentAuthToken();21 return authToken ? authToken.accessToken : null;22 }23 isLoggedIn(): boolean {24 const authToken: AuthToken = this.getCurrentAuthToken();25 return !!authToken && !authToken.isTokenExpired();26 }27 private _retrieveAuthDetails(): AuthToken {28 const storedToken = localStorage.getItem(ImgurAuthService.AUTH_TOKEN_STORAGE_KEY_NAME);29 if (!storedToken) {30 return null;31 }32 return AuthToken.buildFrom(JSON.parse(storedToken));33 }34 login(authToken: AuthToken): void {35 this._storeAuthDetails(authToken);36 }37 private _storeAuthDetails(authToken: AuthToken): void {38 if (!authToken || !authToken.accessToken) {39 return;40 }41 localStorage.setItem(ImgurAuthService.AUTH_TOKEN_STORAGE_KEY_NAME, JSON.stringify(authToken));42 this._authTokenSubject.next(authToken);43 }44 logout(): void {45 this._clearAuthDetails();46 this._authTokenSubject.next(null);47 }48 private _clearAuthDetails(): void {49 localStorage.removeItem(ImgurAuthService.AUTH_TOKEN_STORAGE_KEY_NAME);50 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var argos = require('argos-sdk');2var authToken = argos.authToken;3var username = 'username';4var password = 'password';5authToken(username, password, function(err, token) {6 if (err) {7 console.log(err);8 } else {9 console.log(token);10 }11});12[MIT](

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful