Skip to content

Commit

Permalink
Replace deprecated fetch with http get (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jun 15, 2023
1 parent 424e8d6 commit 28c7e09
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sourced/cool-oneliners/dict.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def dict [...word #word(s) to query the dictionary API but they have to make sen
] {
let query = ($word | str join %20)
let link = ('https://api.dictionaryapi.dev/api/v2/entries/en/' + ($query|str replace ' ' '%20'))
let output = (fetch $link | rename word)
let output = (http get $link | rename word)
let w = ($output.word | first)

if $w == "No Definitions Found" {
Expand Down
2 changes: 1 addition & 1 deletion sourced/gitlab/gitlab.nu
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def call-gitlab [
...args: string
--query: string
] {
fetch -H [Authorization $"Bearer ($env.GITLAB_TOKEN)"] $"($projects)($args|str join)?($query)"
http get -H [Authorization $"Bearer ($env.GITLAB_TOKEN)"] $"($projects)($args|str join)?($query)"
}
# Search files on your GitLab server
def main [
Expand Down
4 changes: 2 additions & 2 deletions sourced/misc/nu_defs.nu
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def mbitly [longurl] {
let username = "user"
let url = $"https://api-ssl.bitly.com/v3/shorten?access_token=($Accesstoken)&login=($username)&longUrl=($longurl)"

let shorturl = (fetch $url | get data | get url)
let shorturl = (http get $url | get data | get url)

$shorturl
$shorturl | xclip -sel clip
Expand Down Expand Up @@ -345,7 +345,7 @@ def trans [

let url = $"https://api.mymemory.translated.net/get?q=($to_translate)&langpair=($from)%7C($to)&of=json&key=($key)&de=($user)"

fetch $url | get responseData | get translatedText
http get $url | get responseData | get translatedText
}
}

Expand Down
2 changes: 1 addition & 1 deletion sourced/update_hosts.nu
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module hosts {
let whitelisted = "(" + ($WHITELIST | str join "|") + ")"
let pattern = ($"0.0.0.0.*($whitelisted).*$")
let OLD_FILE = "/etc/hosts"
let TMP_FILE = (fetch $LINK | lines)
let TMP_FILE = (http get $LINK | lines)

if ($env.LAST_EXIT_CODE == 0) {
let OLD_HEAD = (open $OLD_FILE --raw | lines | first 8 | last 3)
Expand Down
2 changes: 1 addition & 1 deletion sourced/webscraping/shell_stars.nu
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $shell_list | each { |r|
print ""
} else {
let url = $"https://api.github.com/repos/($r.repo)"
let count = (fetch -u $env.GITHUB_USERNAME -p $env.GITHUB_PASSWORD ($url) | get stargazers_count)
let count = (http get -u $env.GITHUB_USERNAME -p $env.GITHUB_PASSWORD ($url) | get stargazers_count)
print $" ($count)"
[[shell repo stars]; [($r.name) ($r.repo) ($count)]]
}
Expand Down

0 comments on commit 28c7e09

Please sign in to comment.