MCPcopy
hub / github.com/Justineo/github-hovercard / request

Function request

src/hovercard.js:1541–1952  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1539 }
1540
1541 let request = function() {
1542 let headers = {}
1543 if (token && !isRetry) {
1544 headers.Authorization = `token ${token}`
1545 }
1546 if (type === EXTRACT_TYPE.COMMIT) {
1547 headers.Accept = 'application/vnd.github.cryptographer-preview'
1548 } else if (type === EXTRACT_TYPE.REPO) {
1549 headers.Accept = 'application/vnd.github.mercy-preview+json'
1550 }
1551
1552 let requestOptions = Object.assign({}, baseOptions, { headers })
1553
1554 function renderMarkdown(content, context) {
1555 let options = {
1556 url: `${API_PREFIX}/markdown`,
1557 method: 'POST',
1558 contentType: 'application/json',
1559 dataType: 'text',
1560 data: JSON.stringify({
1561 text: content,
1562 mode: 'gfm',
1563 context: context
1564 })
1565 }
1566 return $.ajax(Object.assign({}, requestOptions, options))
1567 }
1568
1569 $.ajax(requestOptions)
1570 .done(raw => {
1571 cache[type][value] = raw
1572
1573 // further requests if necessary
1574 switch (type) {
1575 case EXTRACT_TYPE.USER: {
1576 if (raw.type !== 'Organization') {
1577 let todo = 0
1578 let extra = {}
1579
1580 if (value) {
1581 if (!cache.hovercard[value]) {
1582 cache.hovercard[value] = {}
1583 }
1584
1585 let subject = getHovercardSubject() || {}
1586 // '@' for contextless
1587 let subjectSlug = subject
1588 ? `${subject.type}:${subject.id}`
1589 : '@'
1590 if (cache.hovercard[value][subjectSlug]) {
1591 extra.hovercard = cache.hovercard[value][subjectSlug]
1592 } else if (token) {
1593 // get hovercard contexts
1594 todo++
1595
1596 let headers = {
1597 Accept: 'application/vnd.github.hagar-preview+json'
1598 }

Callers 2

handleErrorFunction · 0.70
functionBeforeFunction · 0.70

Calls 6

getHovercardSubjectFunction · 0.70
getCardContentFunction · 0.70
fixRefFunction · 0.70
renderMarkdownFunction · 0.70
removeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected