Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
How release Promise pending with async-await in react

my Code :

const attList = async (areaCode, cityCode) => {
    const url = `http://api.visitkorea.or.kr/openapi/service/rest/KorService/areaBasedList?ServiceKey=${serviceKey}&contentTypeId=12&areaCode=${areaCode}&numOfRows=40&sigunguCode=${cityCode}&MobileOS=ETC&MobileApp=AppTest`;
    try {
        const {data:res} = await axios.get(url)
        const list = res.response.body.items.item;
        return list
    } catch (err) {
        console.log(err);
    }
}

console.log(attList(1, 1))

on Console : enter image description here

PromiseResult is Allright, but I don't know how release PromiseResult from Promise{}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Async functions always return a promise. If the return value of an async function is not explicitly a promise, it will be implicitly wrapped in a promise. Note: Even though the return value of an async function behaves as if it's wrapped in a Promise. resolve, they are not equivalent.

const attList = async (areaCode, cityCode, serviceKey) => {
  const url = `http://api.visitkorea.or.kr/openapi/service/rest/KorService/areaBasedList?ServiceKey=${serviceKey}&contentTypeId=12&areaCode=${areaCode}&numOfRows=40&sigunguCode=${cityCode}&MobileOS=ETC&MobileApp=AppTest`;

  const _url = 'https://jsonplaceholder.typicode.com/todos/1';

  try {
    const data = await axios.get(url);
    console.log(data);
  } catch (err) {
    console.log(err);
  }
};

attList(1, 1, null);

you didn't define serviceKey so I couldn't test it with your URL, but I assure you the syntax is just fine.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!