Skip to content

Instantly share code, notes, and snippets.

@harryhan24
Last active January 2, 2023 13:36
Show Gist options
  • Save harryhan24/1936101784fbc3e59dd644e9772539f9 to your computer and use it in GitHub Desktop.
Save harryhan24/1936101784fbc3e59dd644e9772539f9 to your computer and use it in GitHub Desktop.

POST

cosnt body = {title,content}
axios.post(uri, body, config)

STATUS 분기

axios.post(SCRAP_UTIL_LOAD_URL, {
    validateStatus: (status: number) => {
        return (status >= 200 && status < 300) || status == 404 || status == 409
    }
})

ERROR

/////////////////error
.catch((err: Error | AxiosError) {
  if (axios.isAxiosError(error))  {
    // Access to config, request, and response
  } else {
    // Just a stock error
  }
})

MOCK

const htmlString = fs.readFileSync(__dirname + './__test__/alpha_company.csv', 'utf8')
const axiosMock = new MockAdapter(FmpNetwork.client, {onNoMatch : 'throwException'})
axiosMock.onGet(new RegExp('/v4/shares_float/all'))
    .reply(async () => {
    return [200, require('../__tests__/dummy/fmp_float_all_onlyone.json')]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment